Skip to content

Conversation

@drernie
Copy link
Member

@drernie drernie commented Sep 29, 2025

Summary

  • add automation script to connect to a Quilt stack, capture auth, and emit dev config for the catalog
  • add smoke-test harness that can launch the dev server, drive Chrome, and capture console/network issues
  • document the stack connection workflow and wire new npm scripts (build:config, start:test, start:connected) with required dependencies

Testing

  • Not run (not requested)

@drernie drernie linked an issue Sep 29, 2025 that may be closed by this pull request
@drernie drernie requested review from Copilot, fiskus and nl0 September 29, 2025 20:22
@codecov
Copy link

codecov bot commented Sep 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 39.44%. Comparing base (3dffe28) to head (cad3fef).

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #4567    +/-   ##
========================================
  Coverage   39.44%   39.44%            
========================================
  Files         852      852            
  Lines       36847    36847            
  Branches     6011     5760   -251     
========================================
  Hits        14536    14536            
  Misses      21793    21793            
  Partials      518      518            
Flag Coverage Δ
api-python 91.67% <ø> (ø)
catalog 20.18% <ø> (ø)
lambda 92.60% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds automation scripts for connecting to a Quilt stack and running smoke tests for the catalog application. The scripts enable developers to automatically authenticate with a stack, generate configuration files, and validate the catalog's functionality through automated browser testing.

Key changes:

  • Stack connection script that automates authentication and configuration generation using Chrome DevTools
  • Comprehensive smoke test harness with Chrome browser automation for capturing errors and performance metrics
  • New npm scripts for build configuration, testing, and integrated workflows

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
catalog/package.json Adds new npm scripts and Chrome automation dependencies
catalog/internals/scripts/connect-stack.js Implements stack connection with automated authentication and config generation
catalog/internals/scripts/test-stack.js Provides comprehensive browser testing with error capture and reporting
catalog/internals/scripts/connect-stack.md Documents the stack connection workflow and usage patterns
catalog/CHANGELOG.md Records the addition of stack connection and testing automation
Files not reviewed (1)
  • catalog/package-lock.json: Language not supported
Comments suppressed due to low confidence (1)

catalog/internals/scripts/test-stack.js:1

  • Using eval() poses a security risk as it can execute arbitrary code. Consider using JSON.parse() or a safer parsing method for credential data.
#!/usr/bin/env node

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Summary

This PR adds automation scripts for connecting to Quilt stacks and running smoke tests locally. The implementation includes Chrome DevTools integration for automated credential extraction and webpack dev server integration.

Key Changes:

  • connect-stack.js: Automation script that discovers stack URLs, handles authentication via Chrome, and generates dev configuration
  • test-stack.js: Smoke testing harness with automated browser testing capabilities
  • New npm scripts: build:config, start:test, start:connected for streamlined development workflow
  • Comprehensive documentation explaining the connection workflow

Security Concerns:

  • Use of eval() for parsing credentials creates code injection vulnerability
  • Potential command injection in browser launching logic
  • Chrome automation dependencies (chrome-launcher, chrome-remote-interface) expand attack surface

Overall Assessment:
The scripts provide valuable development automation but contain security vulnerabilities that should be addressed before production use.

Confidence Score: 2/5

  • This PR contains security vulnerabilities that could lead to code execution
  • Score reflects critical security issues: eval() usage enables code injection and command execution risks exist. While the functionality is valuable for development workflows, the security vulnerabilities need immediate attention
  • catalog/internals/scripts/connect-stack.js requires immediate security fixes for eval() and command injection

Important Files Changed

File Analysis

Filename        Score        Overview
catalog/internals/scripts/connect-stack.js 2/5 New automation script with security vulnerabilities: eval() usage and potential command injection
catalog/internals/scripts/test-stack.js 4/5 Smoke test automation script with Chrome integration - appears well-structured with proper validation
catalog/package.json 4/5 Added new Chrome automation dependencies and npm scripts - dependencies appear legitimate

Sequence Diagram

sequenceDiagram
    participant Dev as Developer
    participant Script as connect-stack.js
    participant CLI as quilt3 CLI
    participant Chrome as Chrome Browser
    participant Stack as Quilt Stack
    participant Webpack as Webpack Dev Server
    
    Dev->>Script: npm run start:connected
    Script->>CLI: quilt3 config
    CLI-->>Script: Stack URL
    Script->>Chrome: Launch browser with DevTools
    Chrome->>Stack: Navigate to /login
    Dev->>Stack: Complete authentication
    Stack-->>Chrome: Store tokens in localStorage
    Chrome-->>Script: Extract tokens via CDP
    Script->>Stack: Fetch /config.json
    Stack-->>Script: Stack configuration
    Script->>Script: Generate config.js with auth
    Script->>Webpack: Start dev server
    Webpack-->>Dev: Catalog with stack connection
Loading

5 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

// Use eval to parse JavaScript object (not just JSON)
let credentialsData;
try {
credentialsData = eval('(' + credentialsMatch[1] + ')');
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Using eval() creates a security vulnerability. Replace with JSON.parse() or a safe parser.

Suggested change
credentialsData = eval('(' + credentialsMatch[1] + ')');
credentialsData = JSON.parse(credentialsMatch[1]);
Prompt To Fix With AI
This is a comment left during a code review.
Path: catalog/internals/scripts/connect-stack.js
Line: 443:443

Comment:
logic: Using `eval()` creates a security vulnerability. Replace with `JSON.parse()` or a safe parser.

```suggestion
        credentialsData = JSON.parse(credentialsMatch[1]);
```

How can I resolve this? If you propose a fix, please make it concise.

const loginUrl = `${this.stackUrl}/login`;
const openCommand = process.platform === 'darwin' ? 'open' :
process.platform === 'win32' ? 'start' : 'xdg-open';
exec(`${openCommand} "${loginUrl}"`);
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Potential command injection vulnerability. The loginUrl should be validated or escaped.

Suggested change
exec(`${openCommand} "${loginUrl}"`);
exec(`${openCommand} ${JSON.stringify(loginUrl)}`);
Prompt To Fix With AI
This is a comment left during a code review.
Path: catalog/internals/scripts/connect-stack.js
Line: 298:298

Comment:
logic: Potential command injection vulnerability. The `loginUrl` should be validated or escaped.

```suggestion
      exec(`${openCommand} ${JSON.stringify(loginUrl)}`);
```

How can I resolve this? If you propose a fix, please make it concise.

Copy link
Member

@fiskus fiskus left a comment

Choose a reason for hiding this comment

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

It is a very good, wished and worthful endeavor.

However, there are few things, I'd like to change:

  1. I think "quiltdata/quilt/catalog" and even "quiltdata/quilt" is already bloated, and would be benefited from extracting some parts to standalone repos. This script doesn't use any resources from catalog codebase, so it can easily be placed into standalone repo, e2e repo or meta repo.
  2. I don't know for sure, but I think with a large level of confidence, there are test launchers, that work out of the box with fewer lines of code necessary to run them.

In other words,

  1. I would like to move this code to somewhere else: re-use existing repo, or create some test repo
  2. You can re-use existing tools to run headless web tests


- `npm run connect:stack`: Run the connection script
- `npm run start:connected`: Connect to stack and start dev server
- `npm run start`: Start dev server (expects config to already be generated)
Copy link
Member

Choose a reason for hiding this comment

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

npm start is used for a different task already, and it is not defined in this PR.

I mean, it starts catalog dev server, not the "dev server" from this PR.

### Files Generated/Modified

- `static-dev/config.js`: Generated configuration file (gitignored)
- `.catalog-config.json`: Alternative config location (gitignored)
Copy link
Member

Choose a reason for hiding this comment

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

Seems like hallucination?

- `static-dev/config.js`: Generated configuration file (gitignored)
- `.catalog-config.json`: Alternative config location (gitignored)

Both files are added to `.gitignore` to prevent accidental commits of sensitive configuration data.
Copy link
Member

Choose a reason for hiding this comment

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

static-dev is git-ignored, not specific files in it

@fiskus
Copy link
Member

fiskus commented Sep 30, 2025

I was unable to run scripts, highly likely because Chrome is not installed the expected way (it is installed).

  • Test failed: Server startup timeout
  • Error: Credential collection failed: Automated credential collection failed: The CHROME_PATH environment variable must be set to a Chrome/Chromium executable no older than Chrome stable.

* Test Stack Script
*
* This script automates testing of the catalog by:
* 1. Starting the webpack dev server (npm run start)
Copy link
Member

Choose a reason for hiding this comment

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

I think, it shouldn't run the dev server.

I didn't read the code, but I'd expect this script tests any test stack: localhost:3000, or nightly.quilttest.com, by specifying the host

@@ -0,0 +1,142 @@
<!-- markdownlint-disable MD013 -->
Copy link
Member

Choose a reason for hiding this comment

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

Let's not ignore lint, especially in a new file

@nl0
Copy link
Member

nl0 commented Sep 30, 2025

tbh i'm not quite sure what's the value of this, given all the complexity.
to run a catalog locally you basically just need to wget/curl a config.js from a stack and put it in the static dir, that's it.

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.

feat: connect-to-stack.js

4 participants