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
2 changes: 2 additions & 0 deletions .github/workflows/java-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ on:
jobs:
build_and_test:
runs-on: ubuntu-latest
env:
SCANOSS_API_KEY: ${{ secrets.SC_API_KEY }}
steps:
- uses: actions/checkout@v4

Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/java-native-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ on:
jobs:
build_and_test:
runs-on: ubuntu-latest
env:
SCANOSS_API_KEY: ${{ secrets.SC_API_KEY }}
steps:
- uses: actions/checkout@v4

Expand All @@ -33,6 +35,8 @@ jobs:
needs: [ build_and_test ]
name: Build native on ${{ github.event.inputs.build_env }}
runs-on: ${{ github.event.inputs.build_env }}
env:
SCANOSS_API_KEY: ${{ secrets.SC_API_KEY }}
steps:
- uses: actions/checkout@v4
- uses: graalvm/setup-graalvm@v1
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ jobs:
build_and_test:
name: Build and test java code
runs-on: ubuntu-latest
env:
SCANOSS_API_KEY: ${{ secrets.SC_API_KEY }}
steps:
- uses: actions/checkout@v4

Expand All @@ -34,7 +36,8 @@ jobs:
MAVEN_USERNAME: ${{ secrets.OSSRH_USER_TOKEN }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_PWD_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PWD }}

SCANOSS_API_KEY: ${{ secrets.SC_API_KEY }}

steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -73,6 +76,8 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
env:
SCANOSS_API_KEY: ${{ secrets.SC_API_KEY }}
steps:
- uses: actions/checkout@v4

Expand Down
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.13.1] - 2026-03-25
### Added
- Added support to load a SCANOSS API key from an environment variable (`SCANOSS_API_KEY`) if available.

## [0.13.0] - 2026-02-04
### Added
- Added `file_snippet` scan configuration support in `scanoss.json` for engine tuning parameters (`min_snippet_hits`, `min_snippet_lines`, `honour_file_exts`, `ranking_enabled`, `ranking_threshold`, `skip_headers`, `skip_headers_limit`)
Expand Down Expand Up @@ -149,4 +153,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[0.11.0]: https://github.com/scanoss/scanoss.java/compare/v0.10.1...v0.11.0
[0.12.0]: https://github.com/scanoss/scanoss.java/compare/v0.11.0...v0.12.0
[0.12.1]: https://github.com/scanoss/scanoss.java/compare/v0.12.0...v0.12.1
[0.13.0]: https://github.com/scanoss/scanoss.java/compare/v0.12.1...v0.13.0
[0.13.0]: https://github.com/scanoss/scanoss.java/compare/v0.12.1...v0.13.0
[0.13.1]: https://github.com/scanoss/scanoss.java/compare/v0.13.0...v0.13.1
8 changes: 4 additions & 4 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.13.0</version>
<version>0.13.1</version>
<packaging>jar</packaging>
<name>scanoss.java</name>
<url>https://github.com/scanoss/scanoss.java</url>
Expand Down Expand Up @@ -60,7 +60,7 @@
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.20.0</version>
<version>1.21.0</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand All @@ -72,7 +72,7 @@
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-core</artifactId>
<version>3.2.2</version>
<version>3.3.0</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand All @@ -97,7 +97,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.42</version>
<version>1.18.44</version>
<optional>true</optional>
<scope>compile</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/scanoss/Scanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ private Scanner(Boolean skipSnippets, Boolean allExtensions, Boolean obfuscate,
.skipHeadersLimit(fileSnippetConfig != null && fileSnippetConfig.getSkipHeadersLimit() != null ? fileSnippetConfig.getSkipHeadersLimit() : 0)
.build());
this.scanApi = Objects.requireNonNullElseGet(scanApi, () ->
ScanApi.builder().url(url).apiKey(apiKey).timeout(timeout).retryLimit(retryLimit).flags(scanFlags)
ScanApi.builder().url(url).apiKey(this.apiKey).timeout(timeout).retryLimit(retryLimit).flags(scanFlags)
.sbomType(sbomType).sbom(sbom).customCert(customCert).proxy(proxy).settings(this.settings)
.build());
this.scanFileProcessor = Objects.requireNonNullElseGet(scanFileProcessor, () ->
Expand Down
24 changes: 23 additions & 1 deletion src/main/java/com/scanoss/rest/ScanApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private ScanApi(String scanType, Duration timeout, Integer retryLimit, String ur
this.timeout = timeout;
this.retryLimit = retryLimit;
this.url = url;
this.apiKey = apiKey;
this.apiKey = resolveApiKey(apiKey);
this.flags = flags;
this.sbomType = sbomType;
this.sbom = sbom;
Expand Down Expand Up @@ -130,6 +130,28 @@ private ScanApi(String scanType, Duration timeout, Integer retryLimit, String ur
}
}

/**
* Resolve the API key for Scanoss API
*
* @param apiKey The API key provided by the user
* @return The resolved API key, either from the user-provided value or environment variable
*/
private static String resolveApiKey(String apiKey) {
if (apiKey != null && !apiKey.isBlank()) {
return apiKey;
}
try {
String envApiKey = System.getenv("SCANOSS_API_KEY");
if (envApiKey != null && !envApiKey.isBlank()) {
log.debug( "Using SCANOSS_API_KEY env value");
return envApiKey;
}
} catch (RuntimeException e) {
log.warn("Unable to read SCANOSS_API_KEY from environment: {}", e.getMessage());
}
return apiKey;
}

/**
* Scan the given WFP
*
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/scanoss/TestCli.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void TestScanCommandPositive() {
assertEquals("command should not fail", 0, exitCode);

String[] args2 = new String[]{"-d", "scan", "src/test/java/com", "-T", "2", "--all-hidden",
"--skip-snippets", "--all-extensions", "-F", "256"
"--skip-snippets", "--all-extensions", "-F", "2048"
};
exitCode = new picocli.CommandLine(new CommandLine()).execute(args2);
assertEquals("command should not fail", 0, exitCode);
Expand Down
Loading