-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Collect and report RASP events including Stack traces
- Loading branch information
1 parent
54461ee
commit 83a3a88
Showing
10 changed files
with
297 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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
12 changes: 12 additions & 0 deletions
12
dd-java-agent/appsec/src/main/java/com/datadog/appsec/stack_trace/StackTraceCollection.java
This file contains 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,12 @@ | ||
package com.datadog.appsec.stack_trace; | ||
|
||
import java.util.Collection; | ||
|
||
public class StackTraceCollection { | ||
public final Collection<StackTraceEvent> exploit; | ||
// TODO: Add vulnerability and exception collections for future use in IAST and APM | ||
|
||
public StackTraceCollection(Collection<StackTraceEvent> exploit) { | ||
this.exploit = exploit; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
dd-java-agent/appsec/src/main/java/com/datadog/appsec/stack_trace/StackTraceEvent.java
This file contains 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,35 @@ | ||
package com.datadog.appsec.stack_trace; | ||
|
||
import java.util.List; | ||
|
||
public class StackTraceEvent { | ||
|
||
public final String id; | ||
public final String language = "java"; | ||
public final String message; | ||
public final List<Frame> frames; | ||
|
||
public StackTraceEvent(String id, String message, List<Frame> frames) { | ||
this.id = id; | ||
this.message = message; | ||
this.frames = frames; | ||
} | ||
|
||
public static class Frame { | ||
public final int id; | ||
public final String text; | ||
public final String file; | ||
public final int line; | ||
public final String class_name; | ||
public final String function; | ||
|
||
public Frame(StackTraceElement element, int id) { | ||
this.id = id; | ||
this.text = element.toString(); | ||
this.file = element.getFileName(); | ||
this.line = element.getLineNumber(); | ||
this.class_name = element.getClassName(); | ||
this.function = element.getMethodName(); | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
dd-java-agent/appsec/src/main/java/com/datadog/appsec/util/ObjectFlattener.java
This file contains 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,26 @@ | ||
package com.datadog.appsec.util; | ||
|
||
import com.squareup.moshi.JsonAdapter; | ||
import com.squareup.moshi.Moshi; | ||
|
||
/** | ||
* This class provides a utility method to flatten an object into a Map. The object's fields are | ||
* used as keys in the Map, and the field values are used as values. The field values are | ||
* recursively flattened if they are custom objects. | ||
*/ | ||
public class ObjectFlattener { | ||
|
||
private static final JsonAdapter<Object> JSON_ADAPTER = | ||
new Moshi.Builder().build().adapter(Object.class); | ||
|
||
/** | ||
* Flattens an object into a Map. | ||
* | ||
* @param obj the object to flatten | ||
* @return the flattened object as a Map, or the original object if it's a primitive type or a | ||
* Collection or a Map. Returns null if the input object is null. | ||
*/ | ||
public static Object flatten(Object obj) { | ||
return JSON_ADAPTER.toJsonValue(obj); | ||
} | ||
} |
Oops, something went wrong.