Skip to content

🔒 [Security]: Secure CORS configuration in code generator - #195

Closed
google-labs-jules[bot] wants to merge 2 commits into
mainfrom
fix/secure-cors-code-gen-250672599973076040
Closed

🔒 [Security]: Secure CORS configuration in code generator#195
google-labs-jules[bot] wants to merge 2 commits into
mainfrom
fix/secure-cors-code-gen-250672599973076040

Conversation

@google-labs-jules

Copy link
Copy Markdown
Contributor

🎯 What: The code_generator.py file was generating FastAPI projects with an overly permissive CORS configuration (allow_origins=["*"] along with allow_credentials=True). This fix updates the generator to produce a secure-by-default list of origins for common local development ports (http://localhost:3000, http://localhost:8000, http://localhost:5173).

⚠️ Risk: Generating boilerplate code with wildcard CORS origins allows cross-origin requests from any site. When combined with allowed credentials, this makes the generated applications highly susceptible to Cross-Site Request Forgery (CSRF) and data theft if deployed without modification.

🛡️ Solution: Replaced the unsafe ["*"] wildcard with an explicit array of typical local development URLs in the code generator template. This allows developers to use the generated API from local frontend servers securely while ensuring they must explicitly configure production domains when deploying.


PR created automatically by Jules for task 250672599973076040 started by @groupthinking

@google-labs-jules

Copy link
Copy Markdown
Contributor Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@github-actions

Copy link
Copy Markdown

🔍 PR Validation

⚠️ PR title should follow conventional commits format

@github-actions

github-actions Bot commented May 22, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@github-actions

Copy link
Copy Markdown

🔴 E2E Test Results: FAILURE DETECTED

Metric Value
Status 🔴 RED
Total Tests 2
Passed 15
Failed 2
Deployment https://uvai.io
Test Output
2mms�[22m�[39m
 �[32m✓�[39m tests/e2e/pipeline.test.ts�[2m > �[22mEventRelay E2E — Live Deployment�[2m > �[22mDashboard�[2m > �[22m/dashboard contains agent or pipeline visualization markup�[32m 11�[2mms�[22m�[39m
 �[32m✓�[39m tests/e2e/pipeline.test.ts�[2m > �[22mEventRelay E2E — Live Deployment�[2m > �[22mAPI Health�[2m > �[22mGET /api returns a response (not 404)�[32m 104�[2mms�[22m�[39m
 �[32m✓�[39m tests/e2e/pipeline.test.ts�[2m > �[22mEventRelay E2E — Live Deployment�[2m > �[22mAPI Health�[2m > �[22mPOST /api/pipeline/stream with no body returns 400�[32m 108�[2mms�[22m�[39m
 �[32m✓�[39m tests/e2e/pipeline.test.ts�[2m > �[22mEventRelay E2E — Live Deployment�[2m > �[22mStatic Assets�[2m > �[22mhomepage has proper meta tags�[32m 13�[2mms�[22m�[39m
 �[32m✓�[39m tests/e2e/pipeline.test.ts�[2m > �[22mEventRelay E2E — Live Deployment�[2m > �[22mStatic Assets�[2m > �[22m/features page returns 200�[32m 10�[2mms�[22m�[39m

�[31m⎯⎯⎯⎯⎯⎯⎯�[39m�[1m�[41m Failed Tests 2 �[49m�[22m�[31m⎯⎯⎯⎯⎯⎯⎯�[39m

�[41m�[1m FAIL �[22m�[49m tests/e2e/pipeline.test.ts�[2m > �[22mEventRelay E2E — Live Deployment�[2m > �[22mSSE Pipeline Stream�[2m > �[22mSSE stream emits pipeline_status:running then pipeline_status:complete
�[31m�[1mAssertionError�[22m: expected 'running' to be 'complete' // Object.is equality�[39m

Expected: �[32m"complete"�[39m
Received: �[31m"running"�[39m

�[36m �[2m❯�[22m tests/e2e/pipeline.test.ts:�[2m194:36�[22m�[39m
    �[90m192|�[39m       )�[33m;�[39m
    �[90m193|�[39m       �[35mconst�[39m lastPipeline �[33m=�[39m pipelineEvents[pipelineEvents�[33m.�[39mlength �[33m-�[39m �[34m1�[39m]�[33m;�[39m
    �[90m194|�[39m       �[34mexpect�[39m(lastPipeline�[33m?.�[39mstatus)�[33m.�[39m�[34mtoBe�[39m(�[32m'complete'�[39m)�[33m;�[39m
    �[90m   |�[39m                                    �[31m^�[39m
    �[90m195|�[39m     })�[33m;�[39m
    �[90m196|�[39m

�[31m�[2m⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/2]⎯�[22m�[39m

�[41m�[1m FAIL �[22m�[49m tests/e2e/pipeline.test.ts�[2m > �[22mEventRelay E2E — Live Deployment�[2m > �[22mCloudEvent Schema�[2m > �[22mpipeline_status:complete includes duration and agent count
�[31m�[1mAssertionError�[22m: expected undefined to be defined�[39m
�[36m �[2m❯�[22m tests/e2e/pipeline.test.ts:�[2m298:24�[22m�[39m
    �[90m296|�[39m       )�[33m;�[39m
    �[90m297|�[39m
    �[90m298|�[39m       �[34mexpect�[39m(complete)�[33m.�[39m�[34mtoBeDefined�[39m()�[33m;�[39m
    �[90m   |�[39m                        �[31m^�[39m
    �[90m299|�[39m       �[35mif�[39m (complete) {
    �[90m300|�[39m         �[34mexpect�[39m(complete�[33m.�[39mduration)�[33m.�[39m�[34mtoBeDefined�[39m()�[33m;�[39m

�[31m�[2m⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[2/2]⎯�[22m�[39m


�[2m Test Files �[22m �[1m�[31m1 failed�[39m�[22m�[90m (1)�[39m
�[2m      Tests �[22m �[1m�[31m2 failed�[39m�[22m�[2m | �[22m�[1m�[32m15 passed�[39m�[22m�[90m (17)�[39m
�[2m   Start at �[22m 16:41:13
�[2m   Duration �[22m 109.14s�[2m (transform 58ms, setup 0ms, import 73ms, tests 108.93s, environment 0ms)�[22m


@github-actions

Copy link
Copy Markdown

🔍 PR Validation

⚠️ PR title should follow conventional commits format

@github-actions

Copy link
Copy Markdown

🔴 E2E Test Results: FAILURE DETECTED

Metric Value
Status 🔴 RED
Total Tests 1
Passed 16
Failed 1
Deployment https://uvai.io
Test Output
ne_status:complete includes duration and agent count�[33m 19190�[2mms�[22m�[39m
 �[32m✓�[39m tests/e2e/pipeline.test.ts�[2m > �[22mEventRelay E2E — Live Deployment�[2m > �[22mError Handling�[2m > �[22mmissing URL returns 400, not a hang�[32m 85�[2mms�[22m�[39m
 �[31m×�[39m tests/e2e/pipeline.test.ts�[2m > �[22mEventRelay E2E — Live Deployment�[2m > �[22mError Handling�[2m > �[22minvalid URL returns error event or completes quickly, not a hang�[33m 12798�[2mms�[22m�[39m
�[31m   → expected false to be true // Object.is equality�[39m
 �[32m✓�[39m tests/e2e/pipeline.test.ts�[2m > �[22mEventRelay E2E — Live Deployment�[2m > �[22mDashboard�[2m > �[22m/dashboard returns 200�[32m 59�[2mms�[22m�[39m
 �[32m✓�[39m tests/e2e/pipeline.test.ts�[2m > �[22mEventRelay E2E — Live Deployment�[2m > �[22mDashboard�[2m > �[22m/dashboard contains agent or pipeline visualization markup�[32m 21�[2mms�[22m�[39m
 �[32m✓�[39m tests/e2e/pipeline.test.ts�[2m > �[22mEventRelay E2E — Live Deployment�[2m > �[22mAPI Health�[2m > �[22mGET /api returns a response (not 404)�[32m 47�[2mms�[22m�[39m
 �[32m✓�[39m tests/e2e/pipeline.test.ts�[2m > �[22mEventRelay E2E — Live Deployment�[2m > �[22mAPI Health�[2m > �[22mPOST /api/pipeline/stream with no body returns 400�[32m 39�[2mms�[22m�[39m
 �[32m✓�[39m tests/e2e/pipeline.test.ts�[2m > �[22mEventRelay E2E — Live Deployment�[2m > �[22mStatic Assets�[2m > �[22mhomepage has proper meta tags�[32m 24�[2mms�[22m�[39m
 �[32m✓�[39m tests/e2e/pipeline.test.ts�[2m > �[22mEventRelay E2E — Live Deployment�[2m > �[22mStatic Assets�[2m > �[22m/features page returns 200�[32m 27�[2mms�[22m�[39m

�[31m⎯⎯⎯⎯⎯⎯⎯�[39m�[1m�[41m Failed Tests 1 �[49m�[22m�[31m⎯⎯⎯⎯⎯⎯⎯�[39m

�[41m�[1m FAIL �[22m�[49m tests/e2e/pipeline.test.ts�[2m > �[22mEventRelay E2E — Live Deployment�[2m > �[22mError Handling�[2m > �[22minvalid URL returns error event or completes quickly, not a hang
�[31m�[1mAssertionError�[22m: expected false to be true // Object.is equality�[39m

�[32m- Expected�[39m
�[31m+ Received�[39m

�[32m- true�[39m
�[31m+ false�[39m

�[36m �[2m❯�[22m tests/e2e/pipeline.test.ts:�[2m366:57�[22m�[39m
    �[90m364|�[39m         )�[33m;�[39m
    �[90m365|�[39m         �[90m// Either has a terminal event or stream was empty�[39m
    �[90m366|�[39m         �[34mexpect�[39m(hasTerminalEvent �[33m||�[39m events�[33m.�[39mlength �[33m===�[39m �[34m0�[39m)�[33m.�[39m�[34mtoBe�[39m(�[35mtrue�[39m)�[33m;�[39m
    �[90m   |�[39m                                                         �[31m^�[39m
    �[90m367|�[39m       } �[35melse�[39m {
    �[90m368|�[39m         �[90m// Non-200 is also acceptable (400, 503, etc.)�[39m

�[31m�[2m⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯�[22m�[39m


�[2m Test Files �[22m �[1m�[31m1 failed�[39m�[22m�[90m (1)�[39m
�[2m      Tests �[22m �[1m�[31m1 failed�[39m�[22m�[2m | �[22m�[1m�[32m16 passed�[39m�[22m�[90m (17)�[39m
�[2m   Start at �[22m 17:27:59
�[2m   Duration �[22m 103.96s�[2m (transform 51ms, setup 0ms, import 63ms, tests 103.77s, environment 0ms)�[22m


groupthinking added a commit that referenced this pull request May 27, 2026
…ction (#207)

Resolves conflicts manually — the conflicting hunks were all in tests/e2e/pipeline.test.ts
and .github/workflows/e2e-tests.yml which were already fixed better in #206.
The security-relevant changes are applied cleanly:

- code_generator.py (#193): replace hardcoded SECRET_KEY with os.getenv/secrets.token_urlsafe
- code_generator.py (#195): restrict CORS allow_origins from ["*"] to localhost origins
- real_api_endpoints.py (#196): read ALLOWED_ORIGINS from env; default to localhost origins
- database_cleanup_service.py (#197): validate table name with regex before SQL use;
  quote safe_table_name with double quotes for PRAGMA and DELETE statements
- deployment_manager.py (#200): add path traversal guard (resolve + is_dir check);
  add --ignore-scripts to npm install; use resolved_path for all cwd args
- tests/unit/test_database_cleanup_security.py: new unit tests for SQL injection prevention

Closes #193 #195 #196 #197 #200

https://claude.ai/code/session_01AgA9F82EwazbdB5R2f9nsd

Co-authored-by: Claude <noreply@anthropic.com>
groupthinking added a commit that referenced this pull request May 27, 2026
* chore: trigger uvai.io production deploy

* feat: UVAI UI/UX full refactor — features page, pricing, Nav, LandingNav (#205)

Zero emoji, real product mockups per feature section, SVG icons everywhere, LandingNav with proper cross-page routing and active states.

Co-authored-by: v0[bot] <v0[bot]@users.noreply.github.com>

* test: improve test coverage, fix Vercel build, dashboard auto-select, E2E resilience (#206)

- 155 new unit tests (middleware, API models, error handling)
- Fix Vercel ERESOLVE build failure via .npmrc legacy-peer-deps
- Fix dashboard ?video= URL param auto-select (issue #159)
- Fix next.config.js duplicate redirects/headers
- Fix CI test dependency installation for Python 3.12
- Make SSE stream always emit terminal pipeline_status event
- Make E2E tests resilient to live server degraded mode
- Replace banned dQw4w9WgXcQ video ID with auJzb1D-fag throughout

* fix: remove hardcoded Grok API key (#194)

🎯 What: Removed the hardcoded fallback value for the GROK_API_KEY in TriModelConsensusTool.
⚠️ Risk: Hardcoded API keys in source code can be exploited if the codebase is exposed or leaked, leading to unauthorized API access, quota exhaustion, and potential financial loss.
🛡️ Solution: Removed the hardcoded string so the tool relies strictly on the environment variable, aligning with secure configuration management practices.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>

* feat(web): add privacy/terms/api-docs/app/login routes; noindex prototype pages (#204)

Resolves 404s on /privacy, /terms, /api/docs, /app, /login and ensures
/prototype carries a noindex robots tag. Scope is intentionally narrow and
does not overlap PR #202 (assets, robots, sitemap, JSON-LD, a11y).

- /privacy, /terms: server-rendered legal placeholder pages with proper
  metadata, canonical URLs, and footer links. Plain-language, startup-
  friendly; will be replaced before enterprise contracts.
- /api/docs: human-readable reference matching the documentation pointer
  returned by /api JSON. Lists actual /api/* routes that exist in code.
- /app, /login: server redirects to /dashboard, marked noindex. UVAI has
  no auth gate today, so this matches actual product behavior.
- /prototype: adds a route layout with robots.index=false because the
  underlying page is an internal prototype spec, not a public surface.
- LandingFooter: surfaces Privacy and Terms links now that the pages
  exist.

Build: next build succeeds, 25 routes generated. Type-check and ESLint clean.

Co-authored-by: Claude <claude@anthropic.com>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>

* test: add unit tests for DatabaseOptimizer._calculate_performance_grade (#182)

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>

* fix(security): SECRET_KEY, CORS wildcard, SQL injection, command injection (#207)

Resolves conflicts manually — the conflicting hunks were all in tests/e2e/pipeline.test.ts
and .github/workflows/e2e-tests.yml which were already fixed better in #206.
The security-relevant changes are applied cleanly:

- code_generator.py (#193): replace hardcoded SECRET_KEY with os.getenv/secrets.token_urlsafe
- code_generator.py (#195): restrict CORS allow_origins from ["*"] to localhost origins
- real_api_endpoints.py (#196): read ALLOWED_ORIGINS from env; default to localhost origins
- database_cleanup_service.py (#197): validate table name with regex before SQL use;
  quote safe_table_name with double quotes for PRAGMA and DELETE statements
- deployment_manager.py (#200): add path traversal guard (resolve + is_dir check);
  add --ignore-scripts to npm install; use resolved_path for all cwd args
- tests/unit/test_database_cleanup_security.py: new unit tests for SQL injection prevention

Closes #193 #195 #196 #197 #200

https://claude.ai/code/session_01AgA9F82EwazbdB5R2f9nsd

Co-authored-by: Claude <noreply@anthropic.com>

* chore: move legacy .agent content under .github (#162)

* chore: move legacy agent files into .github

Agent-Logs-Url: https://github.com/groupthinking/EventRelay/sessions/8e79c6e5-9755-40a2-b8b0-73b9ff75249e

Co-authored-by: groupthinking <154503486+groupthinking@users.noreply.github.com>

* docs: fix relocated agent references

Agent-Logs-Url: https://github.com/groupthinking/EventRelay/sessions/8e79c6e5-9755-40a2-b8b0-73b9ff75249e

Co-authored-by: groupthinking <154503486+groupthinking@users.noreply.github.com>

* docs: remove vague agent rule reference

Agent-Logs-Url: https://github.com/groupthinking/EventRelay/sessions/8e79c6e5-9755-40a2-b8b0-73b9ff75249e

Co-authored-by: groupthinking <154503486+groupthinking@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: groupthinking <154503486+groupthinking@users.noreply.github.com>

* chore(web): UVAI Phase 1 — SEO, a11y, missing static assets

Live uvai.io referenced /favicon.ico, /icon.svg, /apple-touch-icon.png but
apps/web/public/ did not exist in the repo, producing 404s. Layout metadata
also pointed metadataBase and og.url at the legacy v0-uvai.vercel.app host
rather than the canonical uvai.io domain.

Changes:
- Add apps/web/public with favicon.ico (multi-res), icon.svg, apple-touch-icon.png,
  og-image.png (1200x630), manifest.json, robots.txt.
- Add apps/web/src/app/sitemap.ts (Next.js Metadata Route sitemap).
- layout.tsx: metadataBase + og.url -> https://uvai.io, add alternates.canonical,
  inject Organization/WebSite/SoftwareApplication JSON-LD, add skip-to-main link.
- page.tsx: <main id=\"main\"> as skip-link target.
- LandingNav.tsx: aria-label=\"Primary\" on nav, aria-labels on brand + GitHub
  external link, visible focus rings on all interactive elements.
- HeroSection.tsx: focus rings on CTAs, honor prefers-reduced-motion for marquee.
- Add CHANGELOG.md with timestamped entry.

Local verification:
- npx eslint on touched files: clean
- npm run build (apps/web): success, /sitemap.xml route generated, TypeScript clean

No production / deploy / DNS / secret changes.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* chore(web): PR #202 review fixes — no dangerouslySetInnerHTML, MD022, skip-link in layout, central SITE_URL

Addresses code review feedback on PR #202.

1. layout.tsx: replace dangerouslySetInnerHTML JSON-LD with React
   <script>{jsonLdString}</script> children. jsonLdString escapes
   `<` -> `<` to prevent any nested `</script>` breakout. Build
   verified: rendered HTML contains exactly one valid JSON-LD block.
   Complies with repo policy that forbids dangerouslySetInnerHTML.

2. CHANGELOG.md: markdownlint MD022 — blank lines after `#### Added`,
   `### Changed`, and `### Notes / known follow-ups (not in this change)`.

3. Skip-to-main-content target moved from `apps/web/src/app/page.tsx`'s
   <main> to the root layout's content wrapper. The link now works on
   every route (dashboard, pricing, features, playground, prototype,
   not-found), not just the homepage. Duplicate `id="main"` removed
   from page.tsx — rendered HTML on `/` now contains exactly one
   `id="main"`.

4. Add apps/web/src/lib/site.ts exporting SITE_URL = 'https://uvai.io'.
   layout.tsx (metadataBase, alternates.canonical, og.url, JSON-LD URLs)
   and sitemap.ts both consume it. Pricing/playground references kept
   as-is — those are mailto: addresses and api.uvai.io examples in
   code samples, not the same axis as the site origin.

Failing CI check (E2E Pipeline Tests) is unrelated to this PR:
- E2E runs vitest against BASE_URL=https://uvai.io (the live deployment)
- Live root returns 200 but is stale (title still "UVAI — Video to Software")
- This PR touches zero files under tests/e2e/, src/youtube_extension/,
  or apps/web/src/app/api/
- Resolution requires a redeploy of the current main, which is outside
  this PR's scope per the original instructions

Local verification:
- npx eslint on touched files: clean (exit 0)
- npm run build (apps/web): ✓ Compiled, TypeScript clean, 21 pages
- Rendered HTML inspection: JSON-LD block present and well-formed;
  id="main" present on /, /pricing, /features, /dashboard, /playground;
  exactly one id="main" on each prerendered page (no duplicates)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: v0[bot] <v0[bot]@users.noreply.github.com>
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: Claude <claude@anthropic.com>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Claude Code <claude-code@anthropic.com>
@github-actions
github-actions Bot deleted the fix/secure-cors-code-gen-250672599973076040 branch June 2, 2026 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant