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
4 changes: 3 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,9 @@ async function componentAnalysis(manifest, opts = {}) {
fs.accessSync(manifest, fs.constants.R_OK)
opts["manifest-type"] = path.basename(manifest)
let provider = match(manifest, availableProviders, opts) // throws error if no matching provider
return await analysis.requestComponent(provider, manifest, theUrl, opts) // throws error request sending failed
const result = await analysis.requestComponent(provider, manifest, theUrl, opts) // throws error request sending failed
result.packageManager = provider.packageManagerName()
return result
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Python_uv from './providers/python_uv.js'
import rustCargoProvider from './providers/rust_cargo.js'

/** @typedef {{ecosystem: string, contentType: string, content: string}} Provided */
/** @typedef {{isSupported: function(string): boolean, validateLockFile: function(string, Object): void, provideComponent: function(string, {}): Provided | Promise<Provided>, provideStack: function(string, {}): Provided | Promise<Provided>, readLicenseFromManifest: function(string): string | null}} Provider */
/** @typedef {{isSupported: function(string): boolean, validateLockFile: function(string, Object): void, provideComponent: function(string, {}): Provided | Promise<Provided>, provideStack: function(string, {}): Provided | Promise<Provided>, readLicenseFromManifest: function(string): string | null, packageManagerName: function(): string}} Provider */

/**
* MUST include all providers here.
Expand Down
8 changes: 8 additions & 0 deletions src/providers/base_java.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ export default class Base_Java {
this.localWrapper = localWrapper
}

/**
* Returns the package manager name (e.g. mvn, gradle)
* @returns {string}
*/
packageManagerName() {
return this.globalBinary
}

/**
* Recursively populates the SBOM instance with the parsed graph
* @param {string} src - Source dependency to start the calculations from
Expand Down
8 changes: 8 additions & 0 deletions src/providers/base_javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@
throw new TypeError("_cmdName must be implemented");
}

/**
* Returns the package manager name (e.g. npm, yarn, pnpm, bun)
* @returns {string} The package manager name
*/
packageManagerName() {
return this._cmdName();
}

/**
* Returns the command arguments for listing dependencies
* @returns {Array<string>} The command arguments
Expand Down Expand Up @@ -175,7 +183,7 @@
* @returns {boolean} True if the lock file exists
*/
validateLockFile(manifestDir, opts = {}) {
return this._findLockFileDir(manifestDir, opts) !== null

Check warning on line 186 in src/providers/base_javascript.js

View workflow job for this annotation

GitHub Actions / Lint and test project (22)

Expected '!=' and instead saw '!=='

Check warning on line 186 in src/providers/base_javascript.js

View workflow job for this annotation

GitHub Actions / Lint and test project (24)

Expected '!=' and instead saw '!=='
}

/**
Expand Down
8 changes: 8 additions & 0 deletions src/providers/base_pyproject.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@ export default class Base_pyproject {
throw new TypeError('_cmdName must be implemented')
}

/**
* Returns the package manager name (e.g. pip, poetry, uv)
* @returns {string}
*/
packageManagerName() {
return this._cmdName()
}

/**
* Resolve dependencies using the tool-specific command and parser.
*
Expand Down
2 changes: 1 addition & 1 deletion src/providers/golang_gomodules.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { filterManifestPathsByDiscoveryIgnore, resolveWorkspaceDiscoveryIgnore }

import { getParser, getRequireQuery } from './gomod_parser.js'

export default { isSupported, validateLockFile, provideComponent, provideStack, readLicenseFromManifest }
export default { isSupported, validateLockFile, provideComponent, provideStack, readLicenseFromManifest, packageManagerName() { return 'go' } }

/** @typedef {import('../provider').Provider} */

Expand Down
2 changes: 1 addition & 1 deletion src/providers/python_pip.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import Python_controller from './python_controller.js'
import { getParser, getIgnoreQuery, getPinnedVersionQuery } from './requirements_parser.js'

export default { isSupported, validateLockFile, provideComponent, provideStack, readLicenseFromManifest }
export default { isSupported, validateLockFile, provideComponent, provideStack, readLicenseFromManifest, packageManagerName() { return 'pip' } }

/** @typedef {{name: string, version: string, dependencies: DependencyEntry[], hashes?: Array<{alg: string, content: string}>}} DependencyEntry */

Expand Down
2 changes: 1 addition & 1 deletion src/providers/rust_cargo.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { getLicense } from '../license/license_utils.js'
import Sbom from '../sbom.js'
import { getCustom, getCustomPath, invokeCommand } from '../tools.js'

export default { isSupported, validateLockFile, provideComponent, provideStack, readLicenseFromManifest }
export default { isSupported, validateLockFile, provideComponent, provideStack, readLicenseFromManifest, packageManagerName() { return 'cargo' } }

/** @typedef {import('../provider').Provider} */

Expand Down
Loading