-
Notifications
You must be signed in to change notification settings - Fork 0
debug(meta-ads): add OAuth exchange logging for debugging #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🚀 Preview Deployments Ready!Your changes have been deployed to preview environments: 📦
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 issues found across 1 file
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="meta-ads/server/main.ts">
<violation number="1" location="meta-ads/server/main.ts:102">
P1: Logging OAuth parameters exposes sensitive credentials (authorization code and code_verifier) to logs. Even for debugging, avoid logging the full `code` and `code_verifier` values as they could be captured in log aggregation systems.</violation>
<violation number="2" location="meta-ads/server/main.ts:134">
P1: Token URL redaction is incomplete - only `appSecret` is replaced, but the URL also contains the sensitive authorization `code` and `code_verifier` in query params. The comment "without secret" is misleading.</violation>
</file>
Reply to cubic to teach it or ask questions. Tag @cubic-dev-ai to re-run a review.
| { method: "GET" }, | ||
| const tokenUrl = `https://graph.facebook.com/${META_API_VERSION}/oauth/access_token?${params.toString()}`; | ||
| console.log( | ||
| "[Meta OAuth] Token URL (without secret):", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: Token URL redaction is incomplete - only appSecret is replaced, but the URL also contains the sensitive authorization code and code_verifier in query params. The comment "without secret" is misleading.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At meta-ads/server/main.ts, line 134:
<comment>Token URL redaction is incomplete - only `appSecret` is replaced, but the URL also contains the sensitive authorization `code` and `code_verifier` in query params. The comment "without secret" is misleading.</comment>
<file context>
@@ -122,16 +129,26 @@ const runtime = withRuntime<Env>({
- { method: "GET" },
+ const tokenUrl = `https://graph.facebook.com/${META_API_VERSION}/oauth/access_token?${params.toString()}`;
+ console.log(
+ "[Meta OAuth] Token URL (without secret):",
+ tokenUrl.replace(appSecret, "***"),
);
</file context>
| redirectUri?: string; | ||
| }) => { | ||
| console.log("[Meta OAuth] exchangeCode called"); | ||
| console.log("[Meta OAuth] oauthParams:", JSON.stringify(oauthParams)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: Logging OAuth parameters exposes sensitive credentials (authorization code and code_verifier) to logs. Even for debugging, avoid logging the full code and code_verifier values as they could be captured in log aggregation systems.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At meta-ads/server/main.ts, line 102:
<comment>Logging OAuth parameters exposes sensitive credentials (authorization code and code_verifier) to logs. Even for debugging, avoid logging the full `code` and `code_verifier` values as they could be captured in log aggregation systems.</comment>
<file context>
@@ -98,7 +98,14 @@ const runtime = withRuntime<Env>({
redirectUri?: string;
}) => {
+ console.log("[Meta OAuth] exchangeCode called");
+ console.log("[Meta OAuth] oauthParams:", JSON.stringify(oauthParams));
+
const appSecret = getEnv("META_APP_SECRET");
</file context>
| console.log("[Meta OAuth] oauthParams:", JSON.stringify(oauthParams)); | |
| console.log("[Meta OAuth] oauthParams:", JSON.stringify({ | |
| ...oauthParams, | |
| code: oauthParams.code ? "[REDACTED]" : undefined, | |
| code_verifier: oauthParams.code_verifier ? "[REDACTED]" : undefined, | |
| })); |
Summary by cubic
Add detailed logging to the Meta Ads OAuth code exchange to make debugging easier. Logs incoming params, presence of META_APP_SECRET (without exposing it), masked token URL, and success/failure responses.
Written for commit a25112c. Summary will update automatically on new commits.