-
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
Changes from 13 commits
699b180
319afa0
5342578
53250b5
d98059c
bcc89c2
dfb305c
8dc6020
bccce35
484bab2
07aa3fc
aec4bb8
30ee3a7
5eb4ab4
ea0d2b3
769416c
8a838b5
d2c2d60
d1ad01a
45ea519
3b911d9
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 /staged/{conceptType} | ||
| new application.NodeJsFunction(new cdk.NestedStack(scope, 'GetConceptsNestedStack'), 'GetConceptsLambda', { | ||
| ...defaultLambdaConfig, | ||
| api: { | ||
| apiGatewayDeployment, | ||
| apiGatewayResource: resources.stagedConceptTypeResource, | ||
| apiGatewayRestApi, | ||
| authorizer: authorizers.edlAuthorizer, | ||
| methods: ['GET'], | ||
| parentPath: 'staged', | ||
| 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 /staged/{conceptType}/{recordId} | ||
| new application.NodeJsFunction(new cdk.NestedStack(scope, 'GetConceptNestedStack'), 'GetConceptLambda', { | ||
| ...defaultLambdaConfig, | ||
| api: { | ||
| apiGatewayDeployment, | ||
| apiGatewayResource: resources.stagedConceptTypeRecordIdResource, | ||
| apiGatewayRestApi, | ||
| authorizer: authorizers.edlAuthorizer, | ||
| methods: ['GET'], | ||
| parentPath: 'stagedConceptTypeVar', | ||
| path: '{recordId}' | ||
| }, | ||
| entry: '../../serverless/src/getConcept/handler.js', | ||
| functionName: 'getConcept', | ||
| functionNamePrefix, | ||
| role: s3LambdaRole | ||
| }) | ||
|
|
||
| // createOrUpdateConcept - PUT /staged/{conceptType} | ||
| new application.NodeJsFunction(new cdk.NestedStack(scope, 'CreateOrUpdateConceptNestedStack'), 'CreateOrUpdateConceptLambda', { | ||
| ...defaultLambdaConfig, | ||
| api: { | ||
| apiGatewayDeployment, | ||
| apiGatewayResource: resources.stagedConceptTypeResource, | ||
| apiGatewayRestApi, | ||
| authorizer: authorizers.stagingApiKeyAuthorizer, | ||
| methods: ['PUT'], | ||
| parentPath: 'staged', | ||
| path: '{conceptType}' | ||
| }, | ||
| entry: '../../serverless/src/createOrUpdateConcept/handler.js', | ||
| environment: { | ||
| ...defaultLambdaConfig.environment, | ||
| STAGING_API_KEY: stagingApiKey | ||
| }, | ||
| functionName: 'createOrUpdateConcept', | ||
| functionNamePrefix, | ||
| role: s3LambdaRole | ||
| }) | ||
|
|
||
| // deleteConcept - DELETE /staged/{conceptType}/{recordId} | ||
| new application.NodeJsFunction(new cdk.NestedStack(scope, 'DeleteConceptNestedStack'), 'DeleteConceptLambda', { | ||
| ...defaultLambdaConfig, | ||
| api: { | ||
| apiGatewayDeployment, | ||
| apiGatewayResource: resources.stagedConceptTypeRecordIdResource, | ||
| apiGatewayRestApi, | ||
| authorizer: authorizers.edlAuthorizer, | ||
| methods: ['DELETE'], | ||
| parentPath: 'stagedConceptTypeVar', | ||
| path: '{recordId}' | ||
| }, | ||
| entry: '../../serverless/src/deleteConcept/handler.js', | ||
| functionName: 'deleteConcept', | ||
| functionNamePrefix, | ||
| role: s3LambdaRole | ||
| }) | ||
|
|
||
| // stageConceptForProduction - POST /providers/{providerId}/{conceptType}/stage-for-production | ||
| new application.NodeJsFunction(new cdk.NestedStack(scope, 'StageConceptForProductionNestedStack'), 'StageConceptForProductionLambda', { | ||
| ...defaultLambdaConfig, | ||
| api: { | ||
| apiGatewayDeployment, | ||
| apiGatewayResource: resources.providersConceptTypeStageForProductionResource, | ||
| apiGatewayRestApi, | ||
| authorizer: authorizers.edlAuthorizer, | ||
| methods: ['POST'], | ||
| parentPath: 'providersProviderIdVarConceptTypeVar', | ||
| path: 'stage-for-production' | ||
| }, | ||
| entry: '../../serverless/src/stageConceptForProduction/handler.js', | ||
| environment: { | ||
| ...defaultLambdaConfig.environment, | ||
| ...productionForwardingConfig | ||
| }, | ||
| functionName: 'stageConceptForProduction', | ||
| functionNamePrefix | ||
| }) | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.