Repository navigation
Add Java Lambda SCA system-test coverage #8182
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 all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
44c29a8
Activate Java Lambda AppSec and API Security system tests
claponcet b2cfbbe
Merge branch 'main' into clara.poncet/java-lambda-response-schema-weblog
claponcet 7702f56
Fix Lambda proxy events and Java weblog payload handling
claponcet 8f13eba
Preserve Lambda request headers in the test proxy
claponcet 7f5e232
Merge branch 'main' into clara.poncet/java-lambda-response-schema-weblog
claponcet 5f2b289
Merge branch 'main' into clara.poncet/java-lambda-response-schema-weblog
claponcet 91fad85
Merge branch 'main' into clara.poncet/java-lambda-response-schema-weblog
claponcet 4335108
Gate Lambda tests requiring fixes on Java 1.68.0-SNAPSHOT
claponcet a0cd2bb
Add Java Lambda SCA system-test coverage
claponcet b11338a
Fix Lambda SCA assertions and test with AppSec disabled
claponcet 693425a
Merge branch 'main' into clara.poncet/java-lambda-sca
claponcet 35b779a
Restore Lambda SCA scenario and test activation after merge
claponcet e348b6f
Enable Java Lambda SCA tests from released 1.68.0
claponcet 9b8ba14
Declare SCA reachability gaps in non-Java Lambda manifests
claponcet c05a4db
Merge branch 'main' into clara.poncet/java-lambda-sca
claponcet 2356c4d
Merge branch 'main' into clara.poncet/java-lambda-sca
claponcet 81127bb
Address Java Lambda SCA reachability review feedback
claponcet 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
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
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
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
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
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
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
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
61 changes: 61 additions & 0 deletions
61
utils/build/docker/java_lambda/src/main/java/com/datadoghq/lambda/ScaReachability.java
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,61 @@ | ||
| package com.datadoghq.lambda; | ||
|
|
||
| import java.io.File; | ||
| import java.lang.reflect.Constructor; | ||
| import java.lang.reflect.InvocationTargetException; | ||
| import java.lang.reflect.Method; | ||
|
|
||
| public class ScaReachability { | ||
|
|
||
| public static void preloadVulnerableClass() { | ||
| // Force LocalFolderExtractor class load during Lambda initialization so the SCA transformer can | ||
| // register GHSA-hf5p-q87m-crj7 with reached=[] before any HTTP request triggers junrarHit(). | ||
| // Without this, the class loads lazily on the first request, so registerCve() and recordHit() | ||
| // fire in the same request with no heartbeat window between them. | ||
| try { | ||
| Class.forName("com.github.junrar.LocalFolderExtractor"); | ||
| } catch (Exception ignored) {} | ||
| } | ||
|
|
||
| public static String junrarHit() { | ||
| try { | ||
| Class<?> cls = Class.forName("com.github.junrar.LocalFolderExtractor"); | ||
| Constructor<?> ctor = cls.getDeclaredConstructors()[0]; | ||
| ctor.setAccessible(true); | ||
| Object instance = ctor.newInstance(new File("/tmp")); | ||
| Class<?> fileHeaderClass = Class.forName("com.github.junrar.rarfile.FileHeader"); | ||
| Method method = cls.getDeclaredMethod("createDirectory", fileHeaderClass); | ||
| method.setAccessible(true); | ||
| method.invoke(instance, (Object) null); | ||
| } catch (InvocationTargetException e) { | ||
| if (!(e.getCause() instanceof NullPointerException)) { | ||
| throw new IllegalStateException("Unexpected exception from Junrar", e.getCause()); | ||
| } | ||
| } catch (ReflectiveOperationException e) { | ||
| throw new IllegalStateException("Failed to invoke Junrar", e); | ||
| } | ||
| return "OK"; | ||
| } | ||
|
|
||
| // Keep the reflective invocation in each method: a shared helper would report the same caller | ||
| // symbol for both endpoints, preventing First_Hit_Wins from distinguishing the call sites. | ||
| public static String junrarHitAlt() { | ||
| try { | ||
| Class<?> cls = Class.forName("com.github.junrar.LocalFolderExtractor"); | ||
| Constructor<?> ctor = cls.getDeclaredConstructors()[0]; | ||
| ctor.setAccessible(true); | ||
| Object instance = ctor.newInstance(new File("/tmp")); | ||
| Class<?> fileHeaderClass = Class.forName("com.github.junrar.rarfile.FileHeader"); | ||
| Method method = cls.getDeclaredMethod("createDirectory", fileHeaderClass); | ||
| method.setAccessible(true); | ||
| method.invoke(instance, (Object) null); | ||
| } catch (InvocationTargetException e) { | ||
| if (!(e.getCause() instanceof NullPointerException)) { | ||
| throw new IllegalStateException("Unexpected exception from Junrar", e.getCause()); | ||
| } | ||
| } catch (ReflectiveOperationException e) { | ||
| throw new IllegalStateException("Failed to invoke Junrar", e); | ||
| } | ||
| return "OK"; | ||
| } | ||
| } |
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
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.