Skip to content
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

feat/isasmendi/add scanoss.json support #17

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
fda811a
feat: SP-1844 parse replace option from bom configuration file
isasmendiagus Nov 14, 2024
fc90ba6
feat: SP-1847 parse replace rule
isasmendiagus Nov 14, 2024
66ac3ad
chore: add test case with multiple purls
isasmendiagus Nov 15, 2024
f9274ef
fix: scan command
isasmendiagus Nov 18, 2024
0918b15
chore: use lombok builder pattern for package settings
isasmendiagus Nov 18, 2024
0601179
feat: use cached components for replacement rules
isasmendiagus Nov 19, 2024
d3d8c81
adds testing files
isasmendiagus Dec 2, 2024
0de844d
feat: SP-1876 Adds lines range on remove rule
isasmendiagus Dec 3, 2024
8754c75
chore: remove unused imports & adds license headers
isasmendiagus Dec 3, 2024
9ca0c07
chore: adds license headers, use final on dtos, add log info ScannerP…
isasmendiagus Dec 9, 2024
98ef79d
chore: update dependencies, update unit tests, handle errors with inv…
isasmendiagus Dec 9, 2024
2a9211a
chore: fix javadoc error
isasmendiagus Dec 12, 2024
a1d3fc3
chore: apply PR comments
isasmendiagus Dec 12, 2024
c5787fa
chore: add missing JavaDocs
isasmendiagus Dec 16, 2024
1864599
chore: creates new target excluding slf4j dependencies
isasmendiagus Dec 16, 2024
af335cc
Apply changes based on feedback
isasmendiagus Dec 19, 2024
9ffd784
SP-1982 adds purl2url convertion
isasmendiagus Dec 20, 2024
5574ed7
documentation and error checking cleanup
eeisegn Dec 31, 2024
fd6dd0a
add nonnull check and javadoc
eeisegn Dec 30, 2024
9b0b55d
added size getters
eeisegn Dec 30, 2024
b701d13
dependency updates
eeisegn Dec 30, 2024
6a38521
formatting and comments
eeisegn Dec 30, 2024
54a3bf7
adding TODOs
eeisegn Dec 30, 2024
e297bac
simplification
eeisegn Dec 30, 2024
ef4d095
chore: adds post processing stage to sdk
isasmendiagus Jan 3, 2025
395cf28
chore: add test for hasOverlappingRanges
isasmendiagus Jan 3, 2025
9d6c4ff
fix: enforce strict path & purl rule matching when both are present
isasmendiagus Jan 9, 2025
94d4216
fix: remove license and vulns when no component is found & change nam…
isasmendiagus Jan 9, 2025
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
56 changes: 48 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.scanoss</groupId>
<artifactId>scanoss</artifactId>
<version>0.7.3</version>
<version>0.8.0</version>
<packaging>jar</packaging>
<name>scanoss.java</name>
<url>https://github.com/scanoss/scanoss.java</url>
Expand Down Expand Up @@ -38,7 +38,7 @@
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<slf4jVersion>2.0.7</slf4jVersion>
<slf4jVersion>2.0.16</slf4jVersion>
<native.maven.plugin.version>0.9.13</native.maven.plugin.version>
<exec.mainClass>com.scanoss.cli.CommandLine</exec.mainClass>
</properties>
Expand Down Expand Up @@ -77,7 +77,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.28</version>
<version>1.18.36</version>
<optional>true</optional>
</dependency>
<dependency>
Expand All @@ -93,7 +93,7 @@
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.16.0</version>
<version>1.17.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand All @@ -108,19 +108,24 @@
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-core</artifactId>
<version>2.8.0</version>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>info.picocli</groupId>
<artifactId>picocli</artifactId>
<version>4.7.4</version>
<version>4.7.6</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
<version>2.11.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.package-url</groupId>
<artifactId>packageurl-java</artifactId>
<version>1.5.0</version>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down Expand Up @@ -148,9 +153,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.6.0</version>
<version>3.7.1</version>
<executions>
<execution>
<id>with-all-dependencies</id>
<phase>package</phase>
<goals>
<goal>single</goal>
Expand All @@ -166,6 +172,40 @@
</descriptorRefs>
</configuration>
</execution>
<execution>
<id>without-slf4j</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>${exec.mainClass}</mainClass>
</manifest>
</archive>
<inlineDescriptors>
<inlineDescriptor>
<id>with-dependencies-excluded-slf4j</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<useProjectArtifact>true</useProjectArtifact>
<unpack>true</unpack>
<excludes>
<exclude>org.slf4j:slf4j-api</exclude>
<exclude>org.slf4j:slf4j-simple</exclude>
</excludes>
</dependencySet>
</dependencySets>
</inlineDescriptor>
</inlineDescriptors>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
Expand Down
32 changes: 28 additions & 4 deletions src/main/java/com/scanoss/Scanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@
*/
package com.scanoss;

import com.scanoss.dto.ScanFileResult;
import com.scanoss.exceptions.ScannerException;
import com.scanoss.exceptions.WinnowingException;
import com.scanoss.processor.FileProcessor;
import com.scanoss.processor.ScanFileProcessor;
import com.scanoss.processor.WfpFileProcessor;
import com.scanoss.rest.ScanApi;
import com.scanoss.settings.Settings;
import com.scanoss.utils.JsonUtils;
import lombok.Builder;
import lombok.Getter;
import lombok.NonNull;
Expand Down Expand Up @@ -89,14 +92,17 @@ public class Scanner {
private ScanApi scanApi;
private ScanFileProcessor scanFileProcessor;
private WfpFileProcessor wfpFileProcessor;
private Settings settings;
private ScannerPostProcessor postProcessor;

@SuppressWarnings("unused")
private Scanner(Boolean skipSnippets, Boolean allExtensions, Boolean obfuscate, Boolean hpsm,
Boolean hiddenFilesFolders, Boolean allFolders, Integer numThreads, Duration timeout,
Integer retryLimit, String url, String apiKey, String scanFlags, String sbomType, String sbom,
Integer snippetLimit, String customCert, Proxy proxy,
Winnowing winnowing, ScanApi scanApi,
ScanFileProcessor scanFileProcessor, WfpFileProcessor wfpFileProcessor
ScanFileProcessor scanFileProcessor, WfpFileProcessor wfpFileProcessor,
Settings settings, ScannerPostProcessor postProcessor
) {
this.skipSnippets = skipSnippets;
this.allExtensions = allExtensions;
Expand Down Expand Up @@ -128,7 +134,9 @@ private Scanner(Boolean skipSnippets, Boolean allExtensions, Boolean obfuscate,
this.wfpFileProcessor = Objects.requireNonNullElseGet(wfpFileProcessor, () -> WfpFileProcessor.builder()
.winnowing(this.winnowing)
.build());
}
this.settings = Objects.requireNonNullElseGet(settings, () -> Settings.builder().build());
this.postProcessor = Objects.requireNonNullElseGet(postProcessor, () ->
ScannerPostProcessor.builder().build()); }

/**
* Generate a WFP/Fingerprint for the given file
Expand Down Expand Up @@ -400,7 +408,8 @@ public String scanFile(@NonNull String filename) throws ScannerException, Winnow
* @return List of scan result strings (in JSON format)
*/
public List<String> scanFolder(@NonNull String folder) {
return processFolder(folder, scanFileProcessor);
List<String> results = processFolder(folder, scanFileProcessor);
return postProcessResults(results);
}

/**
Expand All @@ -411,7 +420,22 @@ public List<String> scanFolder(@NonNull String folder) {
* @return List of scan result strings (in JSON format)
*/
public List<String> scanFileList(@NonNull String folder, @NonNull List<String> files) {
return processFileList(folder, files, scanFileProcessor);
List<String> results = processFileList(folder, files, scanFileProcessor);
return postProcessResults(results);
}

/**
* Post-processes scan results based on BOM (Bill of Materials) settings if available.
* @param results List of raw scan results in JSON string format
* @return Processed results, either modified based on BOM or original results if no BOM exists
*/
private List<String> postProcessResults(List<String> results) {
if (settings.getBom() != null) {
List<ScanFileResult> scanFileResults = JsonUtils.toScanFileResults(results);
List <ScanFileResult> newScanFileResults = this.postProcessor.process(scanFileResults, this.settings.getBom());
return JsonUtils.toRawJsonString(newScanFileResults);
}
return results;
}

}
Loading
Loading