Conversation
…eedback endpoint, restrict device auth Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…for alert IDs, add ACKNOWLEDGED constant
- Remove aws-marketplace:Subscribe and aws-marketplace:ViewSubscriptions from chat query Lambda IAM role; a Lambda should never be able to subscribe to paid Marketplace products
- Scope bedrock:InvokeModel to specific Claude 3.5 Sonnet ARN prefixes instead of wildcard *
- Replace Math.random() alert ID generation with crypto.randomUUID() in api-ingest — eliminates 5-6 char collision window at high throughput, uses built-in Node 20 crypto module
- Add ACKNOWLEDGED constant (TRUE/FALSE string literals) to shared/constants.ts — prevents accidental boolean writes that break the DynamoDB GSI partition key
- Import and use ACKNOWLEDGED constant in api-alerts and api-ingest at all write and query sites
- Add marshallOptions: { removeUndefinedValues: true } to DynamoDB document clients in api-alerts and api-devices — matches the pattern already used in api-ingest, prevents latent runtime errors on optional fields
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Merge origin/main to pick up the test suite from #18, then update the 3 GET /analytics/feedback tests to include cognito:groups=Admin in the authorizer JWT claims, matching the admin-group check this PR adds to the handler. Also adds a new test covering the 403 denial path. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Security hardening (previous commits):
rag-retrieval.tsandfeedback.tswith RDS Data API parameterized queries — eliminates SQL injection vectorcognito:groupsAdmin check toGET /analytics/feedback— closes authorization gap on endpoint that returns all users' query historychat-query.tsthat silently returned ALL device serial numbers when none provided — now returns 403Defensive coding (new commits):
parseIntParamhelper toshared/utils.tswith NaN guard and max-value cap — replace unguardedparseInt()calls across 5 handler files (api-devices,api-alerts,api-telemetry,api-activity,api-journeys); bad input now returns default instead of propagating NaN into DynamoDBgetAllDeviceUidsForSerialfromapi-alertsand import the shared version fromdevice-lookup.tsJSON.parse(event.body)in try/catch in mutation handlers inapi-devices(mergeDevices,updateDeviceBySerial) andapi-commands(sendCommand) — malformed JSON now returns 400 instead of 500console.logcalls intracing.tsbehindDEBUG_TRACING=trueenv var — reduces CloudWatch log volume in productionaws-marketplace:Subscribe/ViewSubscriptionsfrom Lambda IAM role — Lambda should never subscribe to paid Marketplace productsMath.random()alert ID generation withcrypto.randomUUID()— eliminates collision window at high throughputACKNOWLEDGEDshared constant for DynamoDB GSI partition key string values — prevents accidental boolean writes that break queriesTest plan
GET /devices?limit=abcreturns results with the default limit, not a 500GET /alerts?limit=999999returns results capped at 500POST /devices/mergewith invalid JSON body returns 400 with descriptive errorPOST /devices/{sn}/commandswith invalid JSON body returns 400deviceSerialNumbersreturns 403🤖 Generated with Claude Code