Skip to content

Conversation

@xingsy97
Copy link
Collaborator

No description provided.

## Prerequisites

1. [Node.js](https://nodejs.org)
2. Create an Web PubSub For Socket.IO resource
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
2. Create an Web PubSub For Socket.IO resource
2. Create an Web PubSub For Socket.IO resource

Linux:

```bash
export WebPubSubConnectionString="<connection_string>"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about using dotenv package for env reading?

@@ -0,0 +1,44 @@
# Create a chat app with Web PubSub for Socket.IO And GitHub OAuth

## Prerequisites
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this chat app with GitHub OAuth referencing any tutorial? Do you want to mention what are the lines updated specifically for Web PubSub?

Removed pull_request_target trigger for workflows.
const app = express();
const server = require("http").createServer(app);
const store = new session.MemoryStore();
const sessionMiddleware = session({ store: store, secret: "changeit", resave: false, saveUninitialized: false });

Check warning

Code scanning / CodeQL

Clear text transmission of sensitive cookie Medium

Sensitive cookie sent without enforcing SSL encryption.

Copilot Autofix

AI about 2 months ago

To correct the issue, set the cookie.secure property to true in the session middleware options. This enforces that the session cookie will only be sent over HTTPS, protecting it from being intercepted in cleartext. The safest fix is to add a cookie object to the session config (if it’s not already present) and set secure: true within it.

However, for development environments running over plain HTTP, using cookie.secure: true can break authentication because cookies will only be sent over HTTPS. A common pattern is to set cookie.secure conditionally: using true in production, and false during development. But since the CodeQL issue is about cleartext transmission and best-practice code, and unless we've been shown an explicit dev/prod check in the provided code region, defaulting to true is the secure choice for this fix.

Therefore, update the options passed to session() on line 12 of sdk/webpubsub-socketio-extension/examples/chat-with-auth-github/index.js by adding cookie: { secure: true }.

No additional imports or methods are required.


Suggested changeset 1
sdk/webpubsub-socketio-extension/examples/chat-with-auth-github/index.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/sdk/webpubsub-socketio-extension/examples/chat-with-auth-github/index.js b/sdk/webpubsub-socketio-extension/examples/chat-with-auth-github/index.js
--- a/sdk/webpubsub-socketio-extension/examples/chat-with-auth-github/index.js
+++ b/sdk/webpubsub-socketio-extension/examples/chat-with-auth-github/index.js
@@ -9,7 +9,7 @@
 const app = express();
 const server = require("http").createServer(app);
 const store = new session.MemoryStore();
-const sessionMiddleware = session({ store: store, secret: "changeit", resave: false, saveUninitialized: false });
+const sessionMiddleware = session({ store: store, secret: "changeit", resave: false, saveUninitialized: false, cookie: { secure: true } });
 
 app.use(sessionMiddleware);
 app.use(bodyParser.urlencoded({ extended: false }));
EOF
@@ -9,7 +9,7 @@
const app = express();
const server = require("http").createServer(app);
const store = new session.MemoryStore();
const sessionMiddleware = session({ store: store, secret: "changeit", resave: false, saveUninitialized: false });
const sessionMiddleware = session({ store: store, secret: "changeit", resave: false, saveUninitialized: false, cookie: { secure: true } });

app.use(sessionMiddleware);
app.use(bodyParser.urlencoded({ extended: false }));
Copilot is powered by AI and may make mistakes. Always verify output.
document.querySelector('.usernameInput').value = names[idx];
</script>
-->
<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>

Check warning

Code scanning / CodeQL

Inclusion of functionality from an untrusted source Medium

Script loaded from content delivery network with no integrity check.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants