Skip to content

Commit d92bb37

Browse files
authored
feat: update logic to adhere to new EOL-API contract (#290)
1 parent 790da15 commit d92bb37

File tree

14 files changed

+518
-425
lines changed

14 files changed

+518
-425
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
name: "${{matrix.platform}} w/ Node.js ${{matrix.node}}.x"
4747
runs-on: ${{matrix.platform}}
4848
env:
49-
GRAPHQL_HOST: ${{ secrets.GRAPHQL_HOST }}
49+
GRAPHQL_HOST: ${{ secrets.NEW_GRAPHQL_HOST }}
5050
EOL_REPORT_URL: ${{ secrets.EOL_REPORT_URL }}
5151
steps:
5252
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

e2e/scan/eol.test.ts

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import { existsSync, readFileSync, unlinkSync } from 'node:fs';
55
import { mkdir } from 'node:fs/promises';
66
import path from 'node:path';
77
import { describe, it } from 'node:test';
8-
import { fileURLToPath } from 'node:url';
98
import { promisify } from 'node:util';
109
import { runCommand } from '@oclif/test';
1110
import { config, filenamePrefix } from '../../src/config/constants';
1211

1312
const execAsync = promisify(exec);
13+
const fixturesDir = path.resolve(import.meta.dirname, '../fixtures');
1414

1515
describe('environment', () => {
1616
it('should not be configured to run against the production environment', () => {
@@ -26,8 +26,7 @@ describe('default arguments', () => {
2626
// Run the CLI directly with no arguments
2727
const { stdout } = await execAsync('node bin/run.js');
2828

29-
// Match EOL count
30-
match(stdout, /1( .*)End-of-Life \(EOL\)/, 'Should show EOL count');
29+
match(stdout, /[1-9]\d*( .*)End-of-Life \(EOL\)/, 'Should show non-zero EOL count');
3130
});
3231

3332
it('runs scan:eol --json when --json is passed in', async () => {
@@ -59,13 +58,10 @@ describe('default arguments', () => {
5958
});
6059

6160
describe('scan:eol e2e', () => {
62-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
63-
const fixturesDir = path.resolve(__dirname, '../fixtures');
64-
const simplePurls = path.resolve(__dirname, '../fixtures/npm/simple.purls.json');
61+
const simplePurls = path.resolve(fixturesDir, 'npm/simple.purls.json');
6562
const simpleSbom = path.join(fixturesDir, `npm/${filenamePrefix}.sbom.json`);
6663
const reportPath = path.resolve(fixturesDir, `${filenamePrefix}.report.json`);
67-
const upToDatePurls = path.resolve(__dirname, '../fixtures/npm/up-to-date.purls.json');
68-
const emptyPurlsPath = path.resolve(__dirname, '../fixtures/npm/empty.purls.json');
64+
const emptyPurlsPath = path.resolve(fixturesDir, 'npm/empty.purls.json');
6965

7066
async function run(cmd: string) {
7167
// Ensure fixtures directory exists and is clean
@@ -133,7 +129,7 @@ describe('scan:eol e2e', () => {
133129
});
134130

135131
it.skip('scans extra-large.purls.json for EOL components', async () => {
136-
const extraLargePurlsPath = path.resolve(__dirname, '../fixtures/npm/extra-large.purls.json');
132+
const extraLargePurlsPath = path.resolve(fixturesDir, 'npm/extra-large.purls.json');
137133
const cmd = `scan:eol --purls ${extraLargePurlsPath}`;
138134
const { stdout } = await run(cmd);
139135

@@ -171,19 +167,22 @@ describe('scan:eol e2e', () => {
171167

172168
const json = JSON.parse(stdout);
173169
const bootstrap = json.components.find((component) => component.purl.startsWith('pkg:npm/bootstrap@'));
174-
strictEqual(bootstrap?.info.status, 'EOL', 'Should match EOL count');
175-
strictEqual(bootstrap?.info.nesAvailable, true, 'Should match remediation count');
170+
strictEqual(bootstrap?.metadata.isEol, true, 'Bootstrap should be marked as EOL');
171+
strictEqual(
172+
!!bootstrap?.nesRemediation?.remediations?.length,
173+
true,
174+
'Bootstrap should have NES remediation available',
175+
);
176176
});
177177

178178
it('correctly identifies Angular 17 as having a EOL date when using --json flag', async () => {
179-
const angular17Purls = path.resolve(__dirname, '../fixtures/npm/angular-17.purls.json');
179+
const angular17Purls = path.resolve(fixturesDir, 'npm/angular-17.purls.json');
180180
const cmd = `scan:eol --purls=${angular17Purls} --json`;
181181
const { stdout } = await run(cmd);
182182

183183
const json = JSON.parse(stdout);
184184
const angular17 = json.components.find((component) => component.purl.startsWith('pkg:npm/%40angular/core@'));
185-
// Match EOL count
186-
strictEqual(angular17?.info.status, 'EOL', 'Should match EOL status');
185+
strictEqual(angular17?.metadata.isEol, true, 'Angular 17 should be marked as EOL');
187186
});
188187

189188
describe('web report URL', () => {
@@ -210,9 +209,7 @@ describe('scan:eol e2e', () => {
210209
* Please see CONTRIBUTING.md before adding new tests to this section.
211210
*/
212211
describe('with directory flag', () => {
213-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
214-
const simpleDir = path.resolve(__dirname, '../fixtures/npm/simple');
215-
const upToDateDir = path.resolve(__dirname, '../fixtures/npm/up-to-date');
212+
const simpleDir = path.resolve(fixturesDir, 'npm/simple');
216213
const reportPath = path.join(simpleDir, `${filenamePrefix}.report.json`);
217214

218215
async function run(cmd: string) {

0 commit comments

Comments
 (0)