Skip to content

Commit

Permalink
Add env variables NPM_URL, GO_PKG_URL, RUST_CRATES_URL, NUGET_URL (Cy…
Browse files Browse the repository at this point in the history
…cloneDX#1247)

* Fixes CycloneDX#1245

Signed-off-by: Ilya Boyazitov <[email protected]>

* Fix linting issues

Signed-off-by: Ilya Boyazitov <[email protected]>

---------

Signed-off-by: Ilya Boyazitov <[email protected]>
  • Loading branch information
Bizordec authored Jul 16, 2024
1 parent 903ee0c commit 10a35cb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 5 additions & 1 deletion docs/ENV.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ The following environment variables are available to configure the bom generatio
| CDX_MAVEN_INCLUDE_TEST_SCOPE | Whether test scoped dependencies should be included from Maven projects, Default: true |
| ASTGEN_IGNORE_DIRS | Comma separated list of directories to ignore while analyzing using babel. The environment variable is also used by atom and astgen. |
| ASTGEN_IGNORE_FILE_PATTERN | Ignore regex to use |
| PYPI_URL | Override pypi url. Default: https://pypi.org/pypi/ |
| PYPI_URL | Override PyPi URL. Default: https://pypi.org/pypi/ |
| NPM_URL | Override NPM registry URL. Default: https://registry.npmjs.org/ |
| GO_PKG_URL | Override Go pkg URL. Default: https://pkg.go.dev/ |
| RUST_CRATES_URL | Override Rust Crates URL. Default: https://crates.io/api/v1/crates/ |
| NUGET_URL | Override NuGet URL. Default is URL from registration hive "RegistrationsBaseUrl/3.6.0" at NuGet V3 API (https://api.nuget.org/v3/index.json). See more at https://learn.microsoft.com/en-us/nuget/api/registration-base-url-resource/ |
| DOCKER_CONFIG | Alternative path to $HOME/.docker |
| DOCKER_AUTH_CONFIG | Perform docker login prior to invoking cdxgen. The file $HOME/.docker/config.json would be automatically read if available. Base64 encoded (json) with credentials: `{'username': string, 'password': string, 'email': string, 'serveraddress' : string}`. Alternatively, set the below 4 environment variables. |
| DOCKER_USER | Docker username |
Expand Down
9 changes: 5 additions & 4 deletions utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ export async function getSwiftPackageMetadata(pkgList) {
* @param {Array} pkgList Package list
*/
export async function getNpmMetadata(pkgList) {
const NPM_URL = "https://registry.npmjs.org/";
const NPM_URL = process.env.NPM_URL || "https://registry.npmjs.org/";
const cdepList = [];
for (const p of pkgList) {
try {
Expand Down Expand Up @@ -4246,7 +4246,7 @@ export async function getRepoLicense(repoUrl, repoMetadata) {
export async function getGoPkgLicense(repoMetadata) {
const group = repoMetadata.group;
const name = repoMetadata.name;
let pkgUrlPrefix = "https://pkg.go.dev/";
let pkgUrlPrefix = process.env.GO_PKG_URL || "https://pkg.go.dev/";
if (group && group !== "." && group !== name) {
pkgUrlPrefix = `${pkgUrlPrefix + group}/`;
}
Expand Down Expand Up @@ -5152,7 +5152,8 @@ export async function parseGemfileLockData(gemLockData, lockFile) {
* @param {Array} pkgList Package list
*/
export async function getCratesMetadata(pkgList) {
const CRATES_URL = "https://crates.io/api/v1/crates/";
const CRATES_URL =
process.env.RUST_CRATES_URL || "https://crates.io/api/v1/crates/";
const cdepList = [];
for (const p of pkgList) {
try {
Expand Down Expand Up @@ -10933,7 +10934,7 @@ async function queryNuget(p, NUGET_URL) {
* @param {Array} pkgList Package list
*/
export async function getNugetMetadata(pkgList, dependencies = undefined) {
const NUGET_URL = await getNugetUrl();
const NUGET_URL = process.env.NUGET_URL || (await getNugetUrl());
const cdepList = [];
const depRepList = {};
for (const p of pkgList) {
Expand Down

0 comments on commit 10a35cb

Please sign in to comment.