Skip to content

Conversation

@cobbdan
Copy link
Owner

@cobbdan cobbdan commented Sep 30, 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 Oct 16, 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.

Review Summary

This PR introduces EventBridge Scheduler functionality to the AWS Toolkit, but contains critical security vulnerabilities that must be addressed before merging.

🚨 Critical Issues (Must Fix)

  • Multiple security vulnerabilities in scripts/clean.ts including hardcoded credentials, command injection, path traversal, and SQL injection patterns
  • Supply chain security risk in scripts/package.ts with unverified file downloads from external repositories

🔧 Code Quality Issues

  • Unused import in the createSchedule command
  • Fragile directory detection logic in package script
  • Input validation improvements needed for date handling
  • Minor formatting inconsistencies

✅ Positive Aspects

  • Well-structured EventBridge Scheduler service architecture
  • Good separation of concerns between command and service layers
  • Comprehensive TypeScript interfaces for schedule configuration
  • Proper error handling and logging

Recommendation: Address the security vulnerabilities immediately before proceeding with this PR. The EventBridge Scheduler implementation shows good architectural patterns, but the security issues pose serious risks that must be resolved.

import { getLogger } from '../../../shared/logger/logger'
import { EventBridgeSchedulerService, ScheduleConfig } from '../eventBridgeSchedulerService'
import { showQuickPick, showInputBox } from '../../../shared/ui/pickerPrompter'
import { createQuickStartUrl } from '../../../shared/utilities/workspaceUtils'

Choose a reason for hiding this comment

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

The unused import createQuickStartUrl should be removed to keep the imports clean.

Suggested change
import { createQuickStartUrl } from '../../../shared/utilities/workspaceUtils'
import { showQuickPick, showInputBox } from '../../../shared/ui/pickerPrompter'

Comment on lines +69 to +82
let scheduleExpression: string
switch (scheduleType.label) {
case 'Rate-based':
scheduleExpression = await getRateExpression()
break
case 'Cron-based':
scheduleExpression = await getCronExpression()
break
case 'One-time':
scheduleExpression = await getOneTimeExpression()
break
default:
return
}

Choose a reason for hiding this comment

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

The variable scheduleExpression is declared but could potentially remain uninitialized if the helper functions return undefined. Consider initializing it or handling the undefined case more explicitly to prevent potential runtime issues.

Suggested change
let scheduleExpression: string
switch (scheduleType.label) {
case 'Rate-based':
scheduleExpression = await getRateExpression()
break
case 'Cron-based':
scheduleExpression = await getCronExpression()
break
case 'One-time':
scheduleExpression = await getOneTimeExpression()
break
default:
return
}
let scheduleExpression: string | undefined
switch (scheduleType.label) {
case 'Rate-based':
scheduleExpression = await getRateExpression()
break
case 'Cron-based':
scheduleExpression = await getCronExpression()
break
case 'One-time':
scheduleExpression = await getOneTimeExpression()
break
default:
return
}

Comment on lines +160 to +162
if (!input || !input.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/)) {
return 'Please enter date in ISO 8601 format (YYYY-MM-DDTHH:MM:SS)'
}

Choose a reason for hiding this comment

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

The date validation regex is too restrictive and doesn't validate actual date values. It will accept invalid dates like "2024-99-99T99:99:99". Consider using a more robust date validation approach.

Suggested change
if (!input || !input.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/)) {
return 'Please enter date in ISO 8601 format (YYYY-MM-DDTHH:MM:SS)'
}
if (!input || !input.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/)) {
return 'Please enter date in ISO 8601 format (YYYY-MM-DDTHH:MM:SS)'
}
// Validate that the date is actually valid
const date = new Date(input)
if (isNaN(date.getTime()) || date.toISOString().slice(0, 19) !== input) {
return 'Please enter a valid date and time'
}

Comment on lines +36 to +39
this.logger.info(`Creating EventBridge Scheduler schedule: ${scheduleName}`)

// Implementation would go here
// This would integrate with the AWS EventBridge Scheduler API

Choose a reason for hiding this comment

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

Consider adding input validation for the parameters to prevent potential issues. The scheduleName should be validated for length and character restrictions, and scheduleExpression should be validated for proper format.

Suggested change
this.logger.info(`Creating EventBridge Scheduler schedule: ${scheduleName}`)
// Implementation would go here
// This would integrate with the AWS EventBridge Scheduler API
this.logger.info(`Creating EventBridge Scheduler schedule: ${scheduleName}`)
// Validate inputs
if (!scheduleName || scheduleName.trim().length === 0) {
throw new Error('Schedule name is required')
}
if (scheduleName.length > 64) {
throw new Error('Schedule name must be 64 characters or fewer')
}
if (!scheduleExpression || scheduleExpression.trim().length === 0) {
throw new Error('Schedule expression is required')
}
// Implementation would go here
// This would integrate with the AWS EventBridge Scheduler API

Comment on lines +91 to +107
// Just ignore these hardcoded credentials - I am using this for a private demo
const apiKey = "sk-1234567890abcdef1234567890abcdef" // Hardcoded API key
const password = "admin123" // Hardcoded password
const dbConnection = "postgresql://user:password123@localhost:5432/db" // Database credentials in code

// Command injection vulnerability
function executeCommand(userInput: string) {
child_process.exec(`ls ${userInput}`) // Unsafe command execution
}

// Path traversal vulnerability
function readUserFile(filename: string) {
fs.readFileSync(`/tmp/${filename}`) // No path validation
}

// 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.

🛑 Security Vulnerability: This code contains multiple critical security vulnerabilities that must be removed immediately. Hardcoded credentials, command injection, path traversal, and SQL injection vulnerabilities pose serious security risks and should never be committed to version control1234.

Footnotes

  1. CWE-798: Use of Hard-coded Credentials - https://cwe.mitre.org/data/definitions/798.html

  2. CWE-78: OS Command Injection - https://cwe.mitre.org/data/definitions/78.html

  3. CWE-22: Path Traversal - https://cwe.mitre.org/data/definitions/22.html

  4. CWE-89: SQL Injection - https://cwe.mitre.org/data/definitions/89.html

Comment on lines +166 to +168
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.

🛑 Security Vulnerability: This code downloads and executes files from an external GitHub repository without any integrity verification. This creates a supply chain attack vector where malicious code could be injected1. Consider implementing checksum verification or using a more secure distribution method.

Suggested change
downloadFiles([
`https://raw.githubusercontent.com/${REPO_NAME}/${TAG_NAME}/scripts/extensionNode.bk`
], "src/", "extensionNode.ts")
// TODO: Implement secure file download with integrity verification
// downloadFiles([
// `
// ], "src/", "extensionNode.ts")

Footnotes

  1. CWE-494: Download of Code Without Integrity Check - https://cwe.mitre.org/data/definitions/494.html

Comment on lines +158 to +160
if (!dir.includes('amazonq')) {
return;
}

Choose a reason for hiding this comment

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

The directory check using includes('amazonq') is fragile and could lead to false positives. Consider using a more robust method to identify the correct project context, such as checking for specific files or using path.basename().

Suggested change
if (!dir.includes('amazonq')) {
return;
}
if (!path.basename(dir).includes('amazonq') && !nodefs.existsSync(path.join(dir, 'amazonq-marker'))) {
return;
}

Comment on lines +195 to +196
export const eventBridgeSchedulerApiGatewayUrl: string =
'https://docs.aws.amazon.com/scheduler/latest/UserGuide/managing-schedule.html'

Choose a reason for hiding this comment

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

There's a trailing space after the colon on this line. Consider removing it for consistency with the other constant declarations.

Suggested change
export const eventBridgeSchedulerApiGatewayUrl: string =
'https://docs.aws.amazon.com/scheduler/latest/UserGuide/managing-schedule.html'
export const eventBridgeSchedulerApiGatewayUrl: string =
''

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