Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
# Maven
target
.flattened-pom.xml
dependency-reduced-pom.xml

# Gradle
.gradle
Expand Down
67 changes: 67 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,73 @@ By Default, The API algorithm will use native commands of PIP installer as data
It's also possible, to use lightweight Python PIP utility [pipdeptree](https://pypi.org/project/pipdeptree/) as data source instead, in order to activate this,
Need to set environment variable/system property - `EXHORT_PIP_USE_DEP_TREE` to true.

### CLI Support

The Exhort Java API includes a command-line interface for standalone usage.

#### Building the CLI

To build the CLI JAR with all dependencies included:

```shell
mvn clean package
```

This creates two JAR files in the `target/` directory:
- `exhort-java-api.jar` - Library JAR (for programmatic use)
- `exhort-java-api-cli.jar` - CLI JAR (includes all dependencies)

#### Usage

```shell
java -jar target/exhort-java-api-cli.jar <COMMAND> <FILE_PATH> [OPTIONS]
```

#### Commands

**Stack Analysis**
```shell
java -jar exhort-java-api-cli.jar stack <file_path> [--summary|--html]
```
Perform stack analysis on the specified manifest file.

Options:
- `--summary` - Output summary in JSON format
- `--html` - Output full report in HTML format
- (default) - Output full report in JSON format

**Component Analysis**
```shell
java -jar exhort-java-api-cli.jar component <file_path> [--summary]
```
Perform component analysis on the specified manifest file.

Options:
- `--summary` - Output summary in JSON format
- (default) - Output full report in JSON format

#### Examples

```shell
# Stack analysis with JSON output (default)
java -jar exhort-java-api-cli.jar stack /path/to/pom.xml

# Stack analysis with summary
java -jar exhort-java-api-cli.jar stack /path/to/package.json --summary

# Stack analysis with HTML output
java -jar exhort-java-api-cli.jar stack /path/to/build.gradle --html

# Component analysis with JSON output (default)
java -jar exhort-java-api-cli.jar component /path/to/requirements.txt

# Component analysis with summary
java -jar exhort-java-api-cli.jar component /path/to/go.mod --summary

# Show help
java -jar exhort-java-api-cli.jar --help
```

### Image Support

Generate vulnerability analysis report for container images.
Expand Down
90 changes: 87 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<maven-site-plugin.version>4.0.0-M6</maven-site-plugin.version>
<maven-source-plugin.version>3.2.1</maven-source-plugin.version>
<maven-surefire-plugin.version>3.5.3</maven-surefire-plugin.version>
<maven-shade-plugin.version>3.4.1</maven-shade-plugin.version>
<build-helper-maven-plugin.version>3.4.0</build-helper-maven-plugin.version>
<extra-enforcer-rules.version>1.6.2</extra-enforcer-rules.version>
<flatten-maven-plugin.version>1.4.1</flatten-maven-plugin.version>
Expand Down Expand Up @@ -454,6 +455,11 @@ limitations under the License.]]>
<artifactId>spotless-maven-plugin</artifactId>
<version>${spotless-maven-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven-shade-plugin.version}</version>
</plugin>
</plugins>
</pluginManagement>

Expand Down Expand Up @@ -651,6 +657,87 @@ limitations under the License.]]>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.redhat.exhort.cli.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>cli</shadedClassifierName>

<!-- Filters to exclude problematic files -->
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<!-- Exclude module-info.class files to avoid strong encapsulation warnings -->
<exclude>module-info.class</exclude>
<exclude>META-INF/versions/*/module-info.class</exclude>
<!-- Exclude signature files -->
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
<!-- Exclude duplicate MANIFEST.MF files (will be recreated) -->
<exclude>META-INF/MANIFEST.MF</exclude>
</excludes>
</filter>
</filters>

<!-- Transformers to handle overlapping resources -->
<transformers>
<!-- Main class transformer -->
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.redhat.exhort.cli.App</mainClass>
</transformer>

<!-- Service files transformer for Jackson and other services -->
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>

<!-- Append NOTICE files -->
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/NOTICE</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/NOTICE.txt</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/NOTICE.md</resource>
</transformer>

<!-- Append LICENSE files -->
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/LICENSE</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/LICENSE.txt</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/LICENSE.md</resource>
</transformer>

</transformers>

<!-- Create non-verbose output -->
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
Expand Down Expand Up @@ -813,9 +900,6 @@ limitations under the License.]]>
<plugin>
<groupId>de.sormuras.junit</groupId>
<artifactId>junit-platform-maven-plugin</artifactId>
<version>${junit-platform-maven-plugin.version}</version>
<configuration>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
Loading
Loading