-
Notifications
You must be signed in to change notification settings - Fork 46
MMT-4199: Create CRUD api for staged metadata #1509
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
699b180
319afa0
5342578
53250b5
d98059c
bcc89c2
dfb305c
8dc6020
bccce35
484bab2
07aa3fc
aec4bb8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ export interface MmtFunctionsProps { | |
| apiGatewayRestApi: cdk.aws_apigateway.CfnRestApi; | ||
| authorizers: { | ||
| edlAuthorizer: apigateway.CfnAuthorizer; | ||
| stagingApiKeyAuthorizer: apigateway.CfnAuthorizer; | ||
| }; | ||
| // MMT keeps explicit CORS config so API Gateway OPTIONS responses can control: | ||
| // - allowOrigin: which browser origin can call the API | ||
|
|
@@ -26,7 +27,17 @@ export interface MmtFunctionsProps { | |
| allowHeaders: string[]; | ||
| }; | ||
| defaultLambdaConfig: application.NodeJsFunctionProps; | ||
| // UAT-only config for the `stageConceptForProduction` forwarding Lambda. | ||
| // Injected only into that handler, not the shared Lambda environment. | ||
| productionForwardingConfig: { | ||
| PRODUCTION_API_HOST: string; | ||
| PRODUCTION_MMT_HOST: string; | ||
| PRODUCTION_STAGING_API_KEY: string; | ||
| }; | ||
| s3LambdaRole: iam.IRole; | ||
| // Shared secret re-checked in `createOrUpdateConcept`. Injected only into that | ||
| // handler, not the shared Lambda environment. | ||
| stagingApiKey: string; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -43,7 +54,9 @@ export class MmtFunctions extends Construct { | |
| authorizers, | ||
| corsConfig, | ||
| defaultLambdaConfig, | ||
| s3LambdaRole | ||
| productionForwardingConfig, | ||
| s3LambdaRole, | ||
| stagingApiKey | ||
| } = props | ||
|
|
||
| const functionNamePrefix = scope.stackName | ||
|
|
@@ -250,5 +263,102 @@ export class MmtFunctions extends Construct { | |
| functionNamePrefix, | ||
| role: s3LambdaRole | ||
| }) | ||
|
|
||
| // getConcepts - GET /providers/{providerId}/{conceptType} | ||
| new application.NodeJsFunction(new cdk.NestedStack(scope, 'GetConceptsNestedStack'), 'GetConceptsLambda', { | ||
| ...defaultLambdaConfig, | ||
| api: { | ||
| apiGatewayDeployment, | ||
| apiGatewayResource: resources.providersConceptTypeResource, | ||
| apiGatewayRestApi, | ||
| authorizer: authorizers.edlAuthorizer, | ||
| methods: ['GET'], | ||
| parentPath: 'providersProviderIdVar', | ||
| path: '{conceptType}' | ||
| }, | ||
| entry: '../../serverless/src/getConcepts/handler.js', | ||
| functionName: 'getConcepts', | ||
| functionNamePrefix, | ||
| role: s3LambdaRole | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- relevant repository conventions ---'
for f in /tmp/coderabbit-repo-knowledge/nasa-mmt-7e9dc5d8/*/*.md; do
case "$f" in
*cdk*|*security*|*iam*|*lambda*|*mmt*) head -80 "$f";;
esac
done
printf '%s\n' '--- concept integrations ---'
cat -n cdk/mmt/lib/mmt-functions.ts | sed -n '245,335p'
printf '%s\n' '--- role definition and wiring ---'
cat -n cdk/mmt/lib/mmt-stack.ts | sed -n '105,180p'
printf '%s\n' '--- concept-related handlers and bucket usage ---'
rg -n -A8 -B4 'STAGING_CONCEPTS_BUCKET_NAME|staging concepts|concept' serverless/src cdk/mmt/libRepository: nasa/mmt Length of output: 50364 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- permission-boundary references ---'
rg -n -A4 -B4 'NGAPShRoleBoundary|IamRoleCustomResourcesLambdaExecution|s3LambdaRole' cdk serverless .github 2>/dev/null | head -160
printf '%s\n' '--- concept handler S3 calls ---'
for f in serverless/src/getConcepts/handler.js serverless/src/getConcept/handler.js serverless/src/createOrUpdateConcept/handler.js serverless/src/deleteConcept/handler.js; do
echo "### $f"
rg -n -A5 -B5 'getConceptsBucketName|Bucket:|Bucket,|GetObject|PutObject|DeleteObject|ListObjects' "$f"
doneRepository: nasa/mmt Length of output: 14680 Security Misconfiguration (CWE-732): Incorrect Permission Assignment for Critical Resource Reachability: External · Exploitability: Difficult Scope the concept Lambdas to the staging concepts bucket. The four concept Lambdas use 🤖 Prompt for AI Agents |
||
| }) | ||
|
|
||
| // getConcept - GET /providers/{providerId}/{conceptType}/{nativeId} | ||
| new application.NodeJsFunction(new cdk.NestedStack(scope, 'GetConceptNestedStack'), 'GetConceptLambda', { | ||
| ...defaultLambdaConfig, | ||
| api: { | ||
| apiGatewayDeployment, | ||
| apiGatewayResource: resources.providersConceptTypeNativeIdResource, | ||
| apiGatewayRestApi, | ||
| authorizer: authorizers.edlAuthorizer, | ||
| methods: ['GET'], | ||
| parentPath: 'providersProviderIdVarConceptTypeVar', | ||
| path: '{nativeId}' | ||
| }, | ||
| entry: '../../serverless/src/getConcept/handler.js', | ||
| functionName: 'getConcept', | ||
| functionNamePrefix, | ||
| role: s3LambdaRole | ||
| }) | ||
|
|
||
| // createOrUpdateConcept - PUT /providers/{providerId}/{conceptType}/{nativeId} | ||
| new application.NodeJsFunction(new cdk.NestedStack(scope, 'CreateOrUpdateConceptNestedStack'), 'CreateOrUpdateConceptLambda', { | ||
| ...defaultLambdaConfig, | ||
| api: { | ||
| apiGatewayDeployment, | ||
| apiGatewayResource: resources.providersConceptTypeNativeIdResource, | ||
| apiGatewayRestApi, | ||
| authorizer: authorizers.stagingApiKeyAuthorizer, | ||
| methods: ['PUT'], | ||
| parentPath: 'providersProviderIdVarConceptTypeVar', | ||
| path: '{nativeId}' | ||
| }, | ||
| entry: '../../serverless/src/createOrUpdateConcept/handler.js', | ||
| environment: { | ||
| ...defaultLambdaConfig.environment, | ||
| STAGING_API_KEY: stagingApiKey | ||
| }, | ||
| functionName: 'createOrUpdateConcept', | ||
| functionNamePrefix, | ||
| role: s3LambdaRole | ||
| }) | ||
|
|
||
| // deleteConcept - DELETE /providers/{providerId}/{conceptType}/{nativeId} | ||
| new application.NodeJsFunction(new cdk.NestedStack(scope, 'DeleteConceptNestedStack'), 'DeleteConceptLambda', { | ||
| ...defaultLambdaConfig, | ||
| api: { | ||
| apiGatewayDeployment, | ||
| apiGatewayResource: resources.providersConceptTypeNativeIdResource, | ||
| apiGatewayRestApi, | ||
| authorizer: authorizers.edlAuthorizer, | ||
| methods: ['DELETE'], | ||
| parentPath: 'providersProviderIdVarConceptTypeVar', | ||
| path: '{nativeId}' | ||
| }, | ||
| entry: '../../serverless/src/deleteConcept/handler.js', | ||
| functionName: 'deleteConcept', | ||
| functionNamePrefix, | ||
| role: s3LambdaRole | ||
| }) | ||
|
|
||
| // stageConceptForProduction - POST /providers/{providerId}/{conceptType}/{nativeId}/stage-for-production | ||
| new application.NodeJsFunction(new cdk.NestedStack(scope, 'StageConceptForProductionNestedStack'), 'StageConceptForProductionLambda', { | ||
| ...defaultLambdaConfig, | ||
| api: { | ||
| apiGatewayDeployment, | ||
| apiGatewayResource: resources.providersConceptTypeNativeIdStageForProductionResource, | ||
| apiGatewayRestApi, | ||
| authorizer: authorizers.edlAuthorizer, | ||
| methods: ['POST'], | ||
| parentPath: 'providersProviderIdVarConceptTypeVarNativeIdVar', | ||
| path: 'stage-for-production' | ||
| }, | ||
| entry: '../../serverless/src/stageConceptForProduction/handler.js', | ||
| environment: { | ||
| ...defaultLambdaConfig.environment, | ||
| ...productionForwardingConfig | ||
| }, | ||
| functionName: 'stageConceptForProduction', | ||
| functionNamePrefix | ||
| }) | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: nasa/mmt
Length of output: 432
🤖 get_repo_knowledge executed:
get_repo_knowledge nasa/mmt /tmp/coderabbit-repo-knowledge/nasa-mmt-7e9dc5d8/architectureLength of output: 4309
Default the UAT-only production variables before expansion.
When Bamboo omits these variables,
set -umakes each direct expansion abortdockerRunbeforecdk deploy. Use empty defaults:🐛 Proposed fix
📝 Committable suggestion
🧰 Tools
🪛 Shellcheck (0.11.0)
[warning] 90-90: bamboo_PRODUCTION_API_HOST is referenced but not assigned.
(SC2154)
[warning] 91-91: bamboo_PRODUCTION_MMT_HOST is referenced but not assigned.
(SC2154)
[warning] 92-92: bamboo_PRODUCTION_STAGING_API_KEY is referenced but not assigned.
(SC2154)
🤖 Prompt for AI Agents
Source: Linters/SAST tools