@aws/nx-plugin-mcp 1.0.0-rc.38 → 1.0.0-rc.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/aws-nx-mcp.js CHANGED
@@ -21388,6 +21388,7 @@ const NX_VERSION = {
21388
21388
  "make-dir-cli": "4.0.0",
21389
21389
  mariadb: "3.5.3",
21390
21390
  ncp: "2.0.0",
21391
+ npm: "12.0.1",
21391
21392
  "npm-check-updates": "22.2.9",
21392
21393
  "oidc-client-ts": "3.5.0",
21393
21394
  pg: "8.22.0",
@@ -3,10 +3,34 @@ title: Docker Bundling
3
3
  description: Build and deploy Docker images for TypeScript and Python projects in an Nx Plugin for AWS workspace.
4
4
  ---
5
5
 
6
- import { FileTree, Tabs, TabItem } from '@astrojs/starlight/components';
6
+ import { FileTree, Tabs, TabItem, Code } from '@astrojs/starlight/components';
7
7
  import NxCommands from '@components/nx-commands.astro';
8
8
  import Link from '@components/link.astro';
9
9
  import Infrastructure from '@components/infrastructure.astro';
10
+ import TrivyVersion from '@components/trivy-version.astro';
11
+ import { CONTAINER_VERSIONS } from '../../../../../../packages/nx-plugin/src/utils/versions';
12
+
13
+ export const trivyTarget = `{
14
+ "targets": {
15
+ "trivy": {
16
+ "cache": true,
17
+ "inputs": ["default", "^production"],
18
+ "outputs": ["{workspaceRoot}/dist/{projectRoot}/trivy"],
19
+ "executor": "nx:run-commands",
20
+ "options": {
21
+ "commands": [
22
+ "rimraf dist/packages/my-project/trivy",
23
+ "make-dir dist/packages/my-project/trivy",
24
+ "ncp packages/my-project/.trivyignore dist/packages/my-project/trivy/.trivyignore",
25
+ "docker save -o dist/packages/my-project/trivy/image.tar my-scope-my-project:latest",
26
+ "docker run --rm -v \\"./dist/packages/my-project/trivy\\":/scan public.ecr.aws/aquasecurity/trivy:${CONTAINER_VERSIONS.trivy} image --input /scan/image.tar --ignorefile /scan/.trivyignore --scanners vuln --severity HIGH,CRITICAL --ignore-unfixed --exit-code 1 --no-progress -q"
27
+ ],
28
+ "parallel": false
29
+ },
30
+ "dependsOn": ["docker"]
31
+ }
32
+ }
33
+ }`;
10
34
 
11
35
  Several generators (such as <Link path="/guides/ts-agent">`ts#agent`</Link> and <Link path="/guides/py-agent">`py#agent`</Link>) produce a Docker image that is pushed to Amazon ECR and consumed by AWS infrastructure. This guide describes the pattern they follow so that you can apply it to other use cases — for example, running a <Link path="/guides/fastapi">FastAPI</Link> project on Amazon ECS, or deploying a containerised Express server.
12
36
 
@@ -253,6 +277,36 @@ This clears the output directory, then copies both the bundle contents and the `
253
277
 
254
278
  <NxCommands commands={['docker my-project']} />
255
279
 
280
+ ## Scanning Images with Trivy
281
+
282
+ It's good practice to scan your images for known vulnerabilities. The generators that follow this pattern add a `trivy` target which scans the built image with [Trivy](https://trivy.dev/), running from the [ECR-hosted Trivy image](https://gallery.ecr.aws/aquasecurity/trivy), and fails the build on `HIGH` or `CRITICAL` findings.
283
+
284
+ Add a `trivy` target which `dependsOn` your `docker` target. It saves the built image to a tarball and scans it via a workspace-relative bind mount, so the same command works under both `docker` and `finch`:
285
+
286
+ <Code lang="json" code={trivyTarget} />
287
+
288
+ Then make `build` depend on `trivy` so the scan runs as part of a build:
289
+
290
+ ```json
291
+ {
292
+ "targets": {
293
+ "build": {
294
+ "dependsOn": ["trivy"]
295
+ }
296
+ }
297
+ }
298
+ ```
299
+
300
+ <NxCommands commands={['trivy my-project']} />
301
+
302
+ :::tip[Caching skips unchanged images]
303
+ Because the image is fully determined by your project source, declaring `inputs` (here `default` and `^production`, matching the `bundle` target) lets Nx cache the scan and skip re-scanning an image that hasn't changed. Pin the Trivy image version (e.g. <code>trivy:<TrivyVersion /></code>) so scans are reproducible.
304
+ :::
305
+
306
+ :::note[Suppressing findings]
307
+ Trivy reads a `.trivyignore` file (a list of vulnerability IDs, one per line) from the root of your project. `--ignore-unfixed` skips vulnerabilities with no available fix, so the scan only fails on issues you can action by upgrading tooling in your `Dockerfile`. See the [Trivy filtering documentation](https://trivy.dev/latest/docs/configuration/filtering/#by-finding-ids) for details.
308
+ :::
309
+
256
310
  ## Infrastructure
257
311
 
258
312
  Wiring the resulting build-context directory to infrastructure as code is the same for both TypeScript and Python — only the path to the build-context directory differs (`dist/packages/my-project/bundle` for TypeScript, `dist/packages/my-project/docker` for Python).
@@ -475,6 +475,10 @@ In order to build your Agent for Bedrock AgentCore Runtime, a `bundle` target is
475
475
 
476
476
  A `docker` target specific to your Agent is also added, which copies the `Dockerfile` and bundled artifacts into a docker context directory. This co-locates the `Dockerfile` with the built output, allowing CDK to build the Docker image directly using `AgentRuntimeArtifact.fromAsset`.
477
477
 
478
+ ### Image Scanning
479
+
480
+ <Snippet name="trivy-image-scan" parentHeading="Image Scanning" />
481
+
478
482
  ### Observability
479
483
 
480
484
  Your agent is automatically configured with observability using the [AWS Distro for Open Telemetry](https://aws.amazon.com/otel/) (ADOT), by configuring auto-instrumentation in your `Dockerfile`.
@@ -171,6 +171,10 @@ In order to build your MCP server for Bedrock AgentCore Runtime, a `bundle` targ
171
171
 
172
172
  A `docker` target specific to your MCP server is also added, which copies the `Dockerfile` and bundled artifacts into a docker context directory. This co-locates the `Dockerfile` with the built output, allowing CDK to build the Docker image directly using `AgentRuntimeArtifact.fromAsset`.
173
173
 
174
+ ### Image Scanning
175
+
176
+ <Snippet name="trivy-image-scan" parentHeading="Image Scanning" />
177
+
174
178
  ### Observability
175
179
 
176
180
  <Snippet name="mcp/observability" parentHeading="Observability" />
@@ -153,6 +153,10 @@ The database client automatically:
153
153
 
154
154
  <Snippet name="rdb/deploying" parentHeading="Deploying your Database" />
155
155
 
156
+ ### Image Scanning
157
+
158
+ <Snippet name="trivy-image-scan" parentHeading="Image Scanning" />
159
+
156
160
  ### RDS Proxy Configuration
157
161
 
158
162
  <Snippet name="rdb/rds-proxy" parentHeading="RDS Proxy Configuration" />
@@ -336,6 +336,10 @@ The generator configures a `<your-agent-name>-docker` target which copies the `D
336
336
 
337
337
  A `docker` target is also generated which prepares the docker context for all agents if you have multiple defined.
338
338
 
339
+ ### Image Scanning
340
+
341
+ <Snippet name="trivy-image-scan" parentHeading="Image Scanning" />
342
+
339
343
  ### Observability
340
344
 
341
345
  Your agent is automatically configured with observability using the [AWS Distro for Open Telemetry](https://aws.amazon.com/otel/) (ADOT), by configuring auto-instrumentation in your `Dockerfile`.
@@ -178,6 +178,10 @@ The generator configures a `<your-server-name>-docker` target which copies the `
178
178
 
179
179
  A `docker` target is also generated which prepares the docker context for all MCP servers if you have multiple defined.
180
180
 
181
+ ### Image Scanning
182
+
183
+ <Snippet name="trivy-image-scan" parentHeading="Image Scanning" />
184
+
181
185
  ### Observability
182
186
 
183
187
  <Snippet name="mcp/observability" parentHeading="Observability" />
@@ -187,6 +187,10 @@ The Prisma client exposes fully typed models derived from your `prisma/models/`
187
187
 
188
188
  <Snippet name="rdb/deploying" parentHeading="Deploying your Database" />
189
189
 
190
+ ### Image Scanning
191
+
192
+ <Snippet name="trivy-image-scan" parentHeading="Image Scanning" />
193
+
190
194
  ### RDS Proxy Configuration
191
195
 
192
196
  <Snippet name="rdb/rds-proxy" parentHeading="RDS Proxy Configuration" />
@@ -0,0 +1,27 @@
1
+ ---
2
+ title: Container Image Scanning
3
+ ---
4
+
5
+ The Docker image built for this project is scanned for vulnerabilities as part of the build using [Trivy](https://trivy.dev/), running from the [ECR-hosted Trivy image](https://gallery.ecr.aws/aquasecurity/trivy).
6
+
7
+ A `trivy` target is added to your project which scans the built image and **fails the build** if any `HIGH` or `CRITICAL` severity vulnerability is found. The generated `Dockerfile` uses a base image with no known fixable vulnerabilities of these severities at time of generation, and upgrades bundled tooling (such as `npm`) to keep it that way.
8
+
9
+ The scan uses the same container engine as your image build (`docker` or `finch`), so no additional tooling is required. Since the scan is only re-run when the image changes, an unchanged image is not re-scanned.
10
+
11
+ :::caution[Unfixable vulnerabilities are ignored]
12
+ The scan runs with `--ignore-unfixed`, so vulnerabilities without an available fix do not fail the build, since they cannot be actioned by upgrading tooling in your `Dockerfile` — they are not reported in the build's scan output. As new vulnerabilities are disclosed the result of scans may change over time, so review the image periodically by running `trivy image <your-image>` without the flag, and rebuild against a newer base image (or add container steps to apply available patches) once a fix is published.
13
+ :::
14
+
15
+ #### Suppressing Trivy Findings
16
+
17
+ There may be instances where you want to suppress a specific vulnerability, for example when no fix is yet available and you have assessed the risk as acceptable.
18
+
19
+ Add the vulnerability ID (one per line) to the `.trivyignore` file in the root of your project (i.e. next to your `project.json`):
20
+
21
+ ```gitignore
22
+ # .trivyignore
23
+ # node-tar arbitrary file write - not exploitable in our usage
24
+ CVE-2024-XXXXX
25
+ ```
26
+
27
+ For more details on filtering findings, refer to the [Trivy filtering documentation](https://trivy.dev/latest/docs/configuration/filtering/#by-finding-ids).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws/nx-plugin-mcp",
3
- "version": "1.0.0-rc.38",
3
+ "version": "1.0.0-rc.39",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/awslabs/nx-plugin-for-aws.git",