https://github.com/contrast-security-oss/java-sarif
POJOs generated from the Static Analysis Results Interchange Format (SARIF) JSON schema.
https://github.com/contrast-security-oss/java-sarif
Last synced: 9 months ago
JSON representation
POJOs generated from the Static Analysis Results Interchange Format (SARIF) JSON schema.
- Host: GitHub
- URL: https://github.com/contrast-security-oss/java-sarif
- Owner: Contrast-Security-OSS
- License: mit
- Created: 2020-10-23T10:43:08.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-04-22T13:36:14.000Z (about 5 years ago)
- Last Synced: 2025-01-19T21:37:59.079Z (over 1 year ago)
- Language: Java
- Size: 186 KB
- Stars: 22
- Watchers: 7
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Java SARIF
Contains POJOs generated from the [Static Analysis Results Interchange Format
](https://docs.oasis-open.org/sarif/sarif/v2.1.0/sarif-v2.1.0.html) (SARIF)
[JSON schema](https://github.com/oasis-tcs/sarif-spec/blob/master/Schemata/sarif-schema-2.1.0.json).
It uses Jackson for serialising/deserialing from JSON.
## Usage
### Add as a dependency
```xml
com.contrastsecurity
java-sarif
2.0
```
### Developing with Java SARIF
All classes reside in the `com.contrastsecurity.sarif` package. The JSON schema used to generate
them is located in `src/main/resources/schema`.
#### Building Objects
Building is provided with method chaining, e.g. for Message
```java
import com.contrastsecurity.sarif.Message;
// ...
Message message = new Message()
.withText("SQL Injection")
.withMarkdown("# SQL Injection");
```
Public Getters & Setters are provided.
#### Jackson
Classes are decorated with `@JsonInclude(JsonInclude.Include.NON_DEFAULT)` and `@JsonPropertyOrder`
which dictates the order from the JSON schema.
```java
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
// ...
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
@JsonPropertyOrder({
"text",
"markdown",
"id",
"arguments",
"properties"
})
public class Message {
// ...
}
```
This library uses [jsonschema2pojo](https://github.com/joelittlejohn/jsonschema2pojo) for
generation.