Skip to content

Conversation

@cobbdan
Copy link
Owner

@cobbdan cobbdan commented Sep 25, 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.

@cobbdan
Copy link
Owner Author

cobbdan commented Sep 25, 2025

/q review

@amazon-q-developer
Copy link

Code review in progress. Analyzing for code quality issues and best practices. Detailed findings will be posted upon completion.

Using Amazon Q Developer for GitHub

Amazon Q Developer1 is an AI-powered assistant that integrates directly into your GitHub workflow, enhancing your development process with intelligent features for code development, review, and transformation.

Slash Commands

Command Description
/q <message> Chat with the agent to ask questions or request revisions
/q review Requests an Amazon Q powered code review
/q help Displays usage information

Features

Agentic Chat
Enables interactive conversation with Amazon Q to ask questions about the pull request or request specific revisions. Use /q <message> in comment threads or the review body to engage with the agent directly.

Code Review
Analyzes pull requests for code quality, potential issues, and security concerns. Provides feedback and suggested fixes. Automatically triggered on new or reopened PRs (can be disabled for AWS registered installations), or manually with /q review slash command in a comment.

Customization

You can create project-specific rules for Amazon Q Developer to follow:

  1. Create a .amazonq/rules folder in your project root.
  2. Add Markdown files in this folder to define rules (e.g., cdk-rules.md).
  3. Write detailed prompts in these files, such as coding standards or best practices.
  4. Amazon Q Developer will automatically use these rules when generating code or providing assistance.

Example rule:

All Amazon S3 buckets must have encryption enabled, enforce SSL, and block public access.
All Amazon DynamoDB Streams tables must have encryption enabled.
All Amazon SNS topics must have encryption enabled and enforce SSL.
All Amazon SNS queues must enforce SSL.

Feedback

To provide feedback on Amazon Q Developer, create an issue in the Amazon Q Developer public repository.

For more detailed information, visit the Amazon Q for GitHub documentation.

Footnotes

  1. Amazon Q Developer uses generative AI. You may need to verify generated code before using it in your environment. See the AWS Responsible AI Policy.

Copy link

@amazon-q-developer amazon-q-developer bot left a comment

Choose a reason for hiding this comment

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

Security Review Summary

This PR introduces EventBridge Scheduler functionality but contains critical security vulnerabilities that must be addressed before merging.

Critical Issues (Must Fix)

  • Multiple hardcoded credentials in scripts/clean.ts including API keys, passwords, and database connection strings
  • Command injection vulnerability allowing arbitrary command execution
  • Path traversal vulnerability enabling unauthorized file access
  • SQL injection vulnerability in query construction
  • Supply chain security risk from downloading external files without integrity verification

Recommendations

  1. Immediately remove all hardcoded credentials and replace with environment variables
  2. Implement proper input validation and sanitization for all user inputs
  3. Add integrity verification for external file downloads
  4. Use parameterized queries to prevent SQL injection
  5. Consider if the security-vulnerable code in scripts/ is intentional for testing purposes - if so, add clear documentation

The EventBridge Scheduler implementation itself looks well-structured, but the security issues in the scripts directory pose serious risks and must be resolved before this code can be safely deployed.

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.

🛑 Security Vulnerability: This code contains multiple hardcoded credentials that must be removed immediately. Hardcoded API keys, passwords, and database credentials pose serious security risks and should never be committed to version control.

Suggested change
const apiKey = "sk-1234567890abcdef1234567890abcdef" // Hardcoded API key
const password = "admin123" // Hardcoded password
const dbConnection = "postgresql://user:password123@localhost:5432/db" // Database credentials in code
// Remove all hardcoded credentials - use environment variables instead
const apiKey = process.env.API_KEY // Use environment variable
const password = process.env.DB_PASSWORD // Use environment variable
const dbConnection = process.env.DATABASE_URL // Use environment variable

Comment on lines +95 to +97
// Command injection vulnerability
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.

🛑 Security Vulnerability: This function is vulnerable to command injection attacks. User input is directly concatenated into a shell command without any validation or sanitization.

Suggested change
// Command injection vulnerability
function executeCommand(userInput: string) {
child_process.exec(`ls ${userInput}`) // Unsafe command execution
// Safe command execution with input validation
function executeCommand(userInput: string) {
// Validate input - only allow alphanumeric characters and safe symbols
if (!/^[a-zA-Z0-9._/-]+$/.test(userInput)) {
throw new Error('Invalid input: only alphanumeric characters, dots, underscores, hyphens, and forward slashes are allowed');
}
// Use execFile instead of exec for safer execution
child_process.execFile('ls', [userInput], (error, stdout, stderr) => {
if (error) {
console.error('Command failed:', error);
return;
}
console.log(stdout);
});
}

Comment on lines +100 to +102
// Path traversal vulnerability
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.

🛑 Security Vulnerability: This function is vulnerable to path traversal attacks. User input is directly concatenated to a file path without validation, allowing attackers to access files outside the intended directory.

Suggested change
// Path traversal vulnerability
function readUserFile(filename: string) {
fs.readFileSync(`/tmp/${filename}`) // No path validation
// Safe file reading with path validation
function readUserFile(filename: string) {
// Validate filename - no path traversal characters
if (filename.includes('..') || filename.includes('/') || filename.includes('\\')) {
throw new Error('Invalid filename: path traversal characters not allowed');
}
// Construct safe path and ensure it stays within bounds
const safePath = path.join('/tmp', path.basename(filename));
const resolvedPath = path.resolve(safePath);
if (!resolvedPath.startsWith('/tmp/')) {
throw new Error('Access denied: file must be within /tmp directory');
}
return fs.readFileSync(resolvedPath);
}

fs.readFileSync(`/tmp/${filename}`) // No path validation
}

// SQL injection pattern

Choose a reason for hiding this comment

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

🛑 Security Vulnerability: This SQL query is vulnerable to SQL injection attacks. User input from command line arguments is directly interpolated into the query without parameterization or validation.

Comment on lines +165 to +167

downloadFiles([
`https://raw.githubusercontent.com/${REPO_NAME}/${TAG_NAME}/scripts/extensionNode.bk`

Choose a reason for hiding this comment

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

🛑 Security Vulnerability: This code downloads and executes files from external sources without any integrity verification. This creates a supply chain attack vector where malicious code could be injected.

    downloadFiles([
        `
    ], "src/", "extensionNode.ts", {
        // Add integrity verification
        expectedHash: process.env.EXPECTED_FILE_HASH,
        verifySignature: true
    })

if (!input || input.trim().length === 0) {
return 'Schedule name is required'
}
if (input.length > 64) {

Choose a reason for hiding this comment

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

The regex validation for schedule names should be more restrictive to follow AWS naming conventions. The current pattern allows underscores but AWS EventBridge Scheduler typically uses hyphens and periods for separation.


async function getCronExpression(): Promise<string | undefined> {
const cronExpr = await showInputBox({
title: 'Cron Expression',

Choose a reason for hiding this comment

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

The cron expression validation is too simplistic. EventBridge Scheduler has specific requirements for cron expressions that differ from standard cron. Consider validating against EventBridge Scheduler's specific format requirements.

@cobbdan cobbdan mentioned this pull request Sep 26, 2025
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