Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import edu.umd.cs.findbugs.annotations.*;
import org.jitsi.utils.logging2.*;
import org.jitsi.xmpp.util.RedactColibri;
import org.jivesoftware.smack.*;
import org.jivesoftware.smack.debugger.*;
import org.jivesoftware.smack.packet.*;
Expand Down Expand Up @@ -66,13 +67,18 @@ public PacketDebugger(XMPPConnection connection, @NonNull String id)
@Override
public void onIncomingStreamElement(TopLevelStreamElement streamElement)
{
logger.debug(() -> "RCV PKT (" + id + "): " + streamElement.toXML());
logger.debug(() -> "RCV PKT (" + id + "): " + redact(streamElement));
}

@Override
public void onOutgoingStreamElement(TopLevelStreamElement streamElement)
{
logger.debug(() -> "SENT PKT (" + id + "): " + streamElement.toXML());
logger.debug(() -> "SENT PKT (" + id + "): " + redact(streamElement));
}

private static String redact(TopLevelStreamElement streamElement)
{
return RedactColibri.Companion.redactToken(streamElement.toXML().toString());
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Jicofo, the Jitsi Conference Focus.
*
* Copyright @ 2026 - present 8x8, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jitsi.impl.protocol.xmpp.log

import io.kotest.core.spec.style.ShouldSpec
import io.kotest.matchers.string.shouldContain
import io.kotest.matchers.string.shouldNotContain
import org.jitsi.xmpp.extensions.jitsimeet.ConferenceIq
import org.jitsi.xmpp.util.RedactColibri.Companion.redactToken
import org.jxmpp.jid.impl.JidCreate

class PacketDebuggerTest : ShouldSpec({
should("redact the token attribute of a logged ConferenceIq, as done by PacketDebugger") {
val token = "eyJhbGciOiJIUzI1NiJ9.super-secret-jwt"
val iq = ConferenceIq().apply {
room = JidCreate.entityBareFrom("room@conference.example.com")
this.token = token
stanzaId = "id1"
}

val redacted = redactToken(iq.toXML().toString())

redacted shouldNotContain token
redacted shouldContain "room=\"room@conference.example.com\""
redacted shouldContain "token=\"[redacted]\""
}
})
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jitsi-xmpp-extensions</artifactId>
<version>1.0-119-gc67bc81</version>
<version>1.0-120-g80f0eee</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down
Loading