Skip to content
Open
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
8 changes: 4 additions & 4 deletions src/commands/fix/coana-fix-dynamic-sbom-inference.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ describe('socket fix --dynamic-sbom-inference', () => {
}
const uploadManifestFiles = vi.fn()
const generated = {
artifactsFlags: ['--maven-use-only-socket-facts'],
artifactsFlags: ['--use-only-socket-facts-artifacts', 'maven'],
paths: [FACTS],
sidecarFile: '/tmp/socket-fix-facts/sidecar.json',
remove: vi.fn(),
Expand Down Expand Up @@ -155,7 +155,7 @@ describe('socket fix --dynamic-sbom-inference', () => {
{ pathsRelativeTo: '/test/cwd' },
)
const args = coanaCalls('compute-fixes-and-upgrade-purls')[0]!
expect(args).toContain('--maven-use-only-socket-facts')
expect(args).toContain('--use-only-socket-facts-artifacts')
expect(args).toContain('--socket-facts-sidecar')
expect(args[args.indexOf('--socket-facts-sidecar') + 1]).toBe(
generated.sidecarFile,
Expand All @@ -177,7 +177,7 @@ describe('socket fix --dynamic-sbom-inference', () => {
await coanaFix({ ...baseConfig, all: true, ghsas: [] })

const args = coanaCalls('find-vulnerabilities')[0]
expect(args).toContain('--maven-use-only-socket-facts')
expect(args).toContain('--use-only-socket-facts-artifacts')
expect(args).not.toContain('--socket-facts-sidecar')
})

Expand Down Expand Up @@ -225,7 +225,7 @@ describe('socket fix --dynamic-sbom-inference', () => {

expect(mockGenerateSocketFactsForFix).not.toHaveBeenCalled()
expect(coanaCalls('compute-fixes-and-upgrade-purls')[0]).not.toContain(
'--maven-use-only-socket-facts',
'--use-only-socket-facts-artifacts',
)
})

Expand Down
5 changes: 4 additions & 1 deletion src/commands/fix/generated-socket-facts.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ describe('generateSocketFactsForFix', () => {

const { artifactsFlags, sidecarFile } = await generate()

expect(artifactsFlags).toEqual(['--maven-use-only-socket-facts'])
expect(artifactsFlags).toEqual([
'--use-only-socket-facts-artifacts',
'maven',
])
expect(JSON.parse(await fs.readFile(sidecarFile, 'utf8'))).toEqual([])
})

Expand Down
6 changes: 3 additions & 3 deletions src/commands/manifest/generate-recursive-manifests.mts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ function statusOf(loader: Loader | undefined): RecursiveManifestOutcomeStatus {
}

// The options a build's listings take besides the build itself.
export function buildToolScriptOptions(
export function buildListingOptions(
config: Pick<EcosystemBuildConfig, 'bin' | 'buildOpts'>,
excludeBase: string | undefined,
excludePaths: string[] | undefined,
Expand Down Expand Up @@ -338,7 +338,7 @@ async function walkTool(
})

const scriptOpts = (candidate: Candidate) =>
buildToolScriptOptions(
buildListingOptions(
configFor(candidate),
ctx.realCwd,
ctx.excludePaths,
Expand Down Expand Up @@ -765,7 +765,7 @@ export async function buildUncoveredRoot({
covered,
ecosystem,
root,
buildToolScriptOptions(config, excludeBase, excludePaths, context),
buildListingOptions(config, excludeBase, excludePaths, context),
)
) {
return 'covered'
Expand Down
8 changes: 2 additions & 6 deletions src/commands/manifest/setup-recursive-manifest-config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
withoutDisabledFlags,
} from './discover-manifest-roots.mts'
import {
buildToolScriptOptions,
buildListingOptions,
resolveWalkConfig,
socketFactsRunOptions,
} from './generate-recursive-manifests.mts'
Expand Down Expand Up @@ -440,11 +440,7 @@ async function isLoadedBy(
covered,
build.ecosystem,
build.root,
buildToolScriptOptions(
buildConfig(walk, build),
walk.cwd,
walk.excludePaths,
),
buildListingOptions(buildConfig(walk, build), walk.cwd, walk.excludePaths),
)
}

Expand Down
10 changes: 3 additions & 7 deletions src/commands/scan/perform-reachability-analysis.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,7 @@ async function coanaArgsFor(

function factsOnlyArgs(args: string[]): string[] {
return args.flatMap((arg, i) =>
arg === '--maven-use-only-socket-facts'
? [arg]
: arg === '--use-only-socket-facts-artifacts'
? [arg, args[i + 1]!]
: [],
arg.includes('use-only-socket-facts') ? [arg, args[i + 1]!] : [],
)
}

Expand Down Expand Up @@ -370,10 +366,10 @@ describe('performReachabilityAnalysis --use-only-socket-facts-artifacts gating',
expectedSidecar: sidecar,
},
{
name: 'keeps the Maven-only flag older Coana releases know, with an empty sidecar',
name: 'names Maven alone the same way, with an empty sidecar',
factsOnlyTypes: ['maven'],
socketFactsSidecar: undefined,
expected: ['--maven-use-only-socket-facts'],
expected: ['--use-only-socket-facts-artifacts', 'maven'],
expectedSidecar: [],
},
{
Expand Down
6 changes: 1 addition & 5 deletions src/utils/coana.mts
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,8 @@ export function isFactsOnlyTypes(
return !!types.length
}

// Maven alone keeps the older flag, which Coana releases before 15.14.1 also
// know.
export function useOnlySocketFactsArtifactsFlags(
types: FactsOnlyTypes,
): string[] {
return types.length === 1 && types[0] === 'maven'
? ['--maven-use-only-socket-facts']
: ['--use-only-socket-facts-artifacts', [...types].sort().join(',')]
return ['--use-only-socket-facts-artifacts', [...types].sort().join(',')]
}
6 changes: 4 additions & 2 deletions src/utils/coana.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -483,8 +483,10 @@ describe('coana facts-file utils', () => {

describe('useOnlySocketFactsArtifactsFlags', () => {
it.for([
// Maven alone keeps the flag Coana releases before 15.14.1 also know.
{ types: ['maven'], expected: ['--maven-use-only-socket-facts'] },
{
types: ['maven'],
expected: ['--use-only-socket-facts-artifacts', 'maven'],
},
{
types: ['nuget', 'maven'],
expected: ['--use-only-socket-facts-artifacts', 'maven,nuget'],
Expand Down
Loading