-
Notifications
You must be signed in to change notification settings - Fork 3k
fix(credentials): recover from wrapped attachment errors #7232
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f61cd50
test(e2e): align provider attachment checks
sandl99 8512073
fix(credentials): parse wrapped attachment errors
sandl99 3e6bf1c
Merge branch 'main' into fix/e2e-provider-attachment
cjagwani ff04499
Merge remote-tracking branch 'origin/main' into fix/e2e-provider-atta…
sandl99 6950310
Merge branch 'main' into fix/e2e-provider-attachment
sandl99 d5fd3e9
merge: refresh PR #7232 against main
senthilr-nv 2c73222
merge: refresh PR #7232 against current main
senthilr-nv 9c00990
merge: refresh PR #7232 for review
senthilr-nv a787cd1
merge: refresh PR #7232 for review
senthilr-nv 5352e85
merge: refresh PR #7232 for review
senthilr-nv c4a9b21
merge: refresh PR #7232 for review
senthilr-nv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| export type ForbiddenLeakPattern = [name: string, value: string]; | ||
|
|
||
| export function bedrockRuntimeForbiddenLeakPatterns(options: { | ||
| adapterToken: string; | ||
| bedrockHostname: string; | ||
| compatibleKey: string; | ||
| }): ForbiddenLeakPattern[] { | ||
| return [ | ||
| ["fake user key", options.compatibleKey], | ||
| ["adapter token", options.adapterToken], | ||
| ["AWS bearer env name", "AWS_BEARER_TOKEN_BEDROCK"], | ||
| ["raw Bedrock hostname", options.bedrockHostname], | ||
| ]; | ||
| } | ||
|
|
||
| export function findForbiddenLeaks( | ||
| text: string, | ||
| label: string, | ||
| patterns: ForbiddenLeakPattern[], | ||
| ): string[] { | ||
| const locations: string[] = []; | ||
| let current = label; | ||
| for (const line of text.split("\n")) { | ||
| if (line.startsWith("@@NEMOCLAW_E2E_FILE@@ ")) { | ||
| current = line.slice("@@NEMOCLAW_E2E_FILE@@ ".length); | ||
| continue; | ||
| } | ||
| for (const [name, value] of patterns) { | ||
| if (value && line.includes(value)) locations.push(`${name}: ${current}`); | ||
| } | ||
| } | ||
| return [...new Set(locations)].sort(); | ||
| } |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { describe, expect, it } from "vitest"; | ||
| import { | ||
| bedrockRuntimeForbiddenLeakPatterns, | ||
| findForbiddenLeaks, | ||
| } from "../fixtures/bedrock-runtime-leak-scan.ts"; | ||
|
|
||
| describe("Bedrock Runtime leak scan", () => { | ||
| const patterns = bedrockRuntimeForbiddenLeakPatterns({ | ||
| adapterToken: "adapter-secret-value", | ||
| bedrockHostname: "bedrock.example.test", | ||
| compatibleKey: "user-secret-value", | ||
| }); | ||
|
|
||
| it("allows the managed provider credential name without allowing its token value", () => { | ||
| expect( | ||
| findForbiddenLeaks( | ||
| "@@NEMOCLAW_E2E_FILE@@ /proc/42/environ\nNEMOCLAW_BEDROCK_RUNTIME_ADAPTER_TOKEN=[managed]", | ||
| "sandbox snapshot", | ||
| patterns, | ||
| ), | ||
| ).toEqual([]); | ||
|
|
||
| expect( | ||
| findForbiddenLeaks( | ||
| "@@NEMOCLAW_E2E_FILE@@ /proc/42/environ\nadapter-secret-value", | ||
| "sandbox snapshot", | ||
| patterns, | ||
| ), | ||
| ).toEqual(["adapter token: /proc/42/environ"]); | ||
| }); | ||
|
|
||
| it("reports other Bedrock credentials and routing details at their source", () => { | ||
| expect( | ||
| findForbiddenLeaks( | ||
| [ | ||
| "@@NEMOCLAW_E2E_FILE@@ config.json", | ||
| "user-secret-value", | ||
| "AWS_BEARER_TOKEN_BEDROCK", | ||
| "@@NEMOCLAW_E2E_FILE@@ runtime.log", | ||
| "bedrock.example.test", | ||
| ].join("\n"), | ||
| "sandbox snapshot", | ||
| patterns, | ||
| ), | ||
| ).toEqual([ | ||
| "AWS bearer env name: config.json", | ||
| "fake user key: config.json", | ||
| "raw Bedrock hostname: runtime.log", | ||
| ]); | ||
| }); | ||
| }); | ||
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.