Skip to content

Commit e6c0302

Browse files
edburnsCopilot
andcommitted
Suppress CodeQL weak-crypto alert for RFC 6455 WebSocket handshake SHA-1
The WebSocket protocol (RFC 6455 §4.2.2) mandates SHA-1 for computing the Sec-WebSocket-Accept header. This is not used for security purposes. Added both @SuppressWarnings and lgtm suppression comments. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: c4e523e3-9d39-4598-90ec-54d959c44ce8
1 parent 816bc9e commit e6c0302

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

java/sdk/src/test/java/com/github/copilot/FakeUpstreamServer.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,10 @@ private void serveHttp(InputStream in, OutputStream out, String path, Map<String
162162

163163
private void serveWebSocket(InputStream in, OutputStream out, Map<String, String> headers) throws Exception {
164164
String key = headers.get("sec-websocket-key");
165-
MessageDigest sha1 = MessageDigest.getInstance("SHA-1");
165+
// SHA-1 is mandated by the WebSocket protocol (RFC 6455 §4.2.2) for the
166+
// Sec-WebSocket-Accept handshake hash. This is NOT used for security purposes.
167+
@SuppressWarnings("codeql[java/weak-cryptographic-algorithm]")
168+
MessageDigest sha1 = MessageDigest.getInstance("SHA-1"); // lgtm[java/weak-cryptographic-algorithm]
166169
byte[] digest = sha1.digest((key + WS_MAGIC).getBytes(StandardCharsets.US_ASCII));
167170
String accept = Base64.getEncoder().encodeToString(digest);
168171
String response = "HTTP/1.1 101 Switching Protocols\r\n" + "Upgrade: websocket\r\n" + "Connection: Upgrade\r\n"

0 commit comments

Comments
 (0)