Skip to content

Commit

Permalink
Merge pull request #159 from pippolino/vulnerability-data-directory
Browse files Browse the repository at this point in the history
Restore dependency check installer path #158
  • Loading branch information
pippolino authored Apr 10, 2024
2 parents e9619bd + a98c4ce commit 7db2124
Show file tree
Hide file tree
Showing 14 changed files with 644 additions and 1,927 deletions.
30 changes: 18 additions & 12 deletions Tasks/DependencyCheck/Tests/L0.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import fs = require('fs-extra')
import assert = require('assert');
import path = require('path');
import * as ttm from 'azure-pipelines-task-lib/mock-test';
import * as path from 'path';
import * as fs from 'fs-extra';
import * as Mocha from 'mocha';
import assert from 'assert';

describe('DependencyCheck Suite', function () {
this.timeout(parseInt(process.env.TASK_TEST_TIMEOUT) || 20000);

before(() => {
before((done) => {
const dataPath = path.join(__dirname, "data");
const dcPath = path.join(dataPath, "dependency-check");
const logPath = path.join(dcPath, "log");
Expand All @@ -27,29 +27,35 @@ describe('DependencyCheck Suite', function () {
process.env['BUILD_REPOSITORY_NAME'] = "MyRepo";
process.env['BUILD_SOURCEBRANCHNAME'] = "master";
process.env['BUILD_SOURCEVERSION'] = "122a24f";
process.env['BUILD_SOURCESDIRECTORY'] = __dirname;
//process.env['BUILD_SOURCESDIRECTORY'] = __dirname;
process.env['BUILDCONFIGURATION'] = "Debug";
process.env['BUILDPLATFORM'] = "Any CPU";
process.env['SYSTEM_ACCESSTOKEN'] = "";
process.env['SYSTEM_DEFINITIONNAME'] = "MyDefinitionName";
process.env['SYSTEM_TEAMFOUNDATIONSERVERURI'] = "https://myurl.de/mycollection/";
process.env['SYSTEM_TEAMPROJECT'] = "PSItraffic";
process.env['COMMON_TESTRESULTSDIRECTORY'] = "data";

done();
});

after(() => {
});

it('Basic execution', (done: Mocha.Done) => {
let tp: string = path.join(__dirname, 'L0BasicExecution.js');
let tr: ttm.MockTestRunner = new ttm.MockTestRunner(tp);
this.timeout(1000);

tr.run();
const tp: string = path.join(__dirname, 'L0BasicExecution.js');
const tr: ttm.MockTestRunner = new ttm.MockTestRunner(tp);

assert(tr.invokedToolCount === 0, 'should not run anything');
assert(tr.stderr.length === 0, 'should not have written to stderr');
assert(tr.succeeded, 'task should have succeeded');
tr.runAsync().then(() => {
assert(tr.invokedToolCount === 0, 'should not run anything');
assert(tr.stderr.length === 0, 'should not have written to stderr');
assert(tr.succeeded, 'task should have succeeded');

done();
done();
}).catch((error) => {
done(error);
});
});
});
28 changes: 14 additions & 14 deletions Tasks/DependencyCheck/Tests/L0BasicExecution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@ import ma = require('azure-pipelines-task-lib/mock-answer');
import tmrm = require('azure-pipelines-task-lib/mock-run');
import path = require('path');

let taskPath = path.join(__dirname, '..', 'dependency-check-build-task.js');
let tr: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath);
const taskPath = path.join(__dirname, '..', 'dependency-check-build-task.js');
const tmr: tmrm.TaskMockRunner = new tmrm.TaskMockRunner(taskPath);

tr.setInput('enableVerbose', 'true');
tr.setInput('projectName', 'Example Project Name');
tr.setInput('scanPath', '**/*.jar');
tr.setInput('format', 'HTML,SARIF');
tr.setInput('enableExperimental', 'false');
tr.setInput('enableRetired', 'false');
tr.setInput('uploadReports', 'true');
tr.setInput('uploadSARIFReport', 'true');
tr.setInput('warnOnCVSSViolation', 'true');
tr.setInput('reportsDirectory', "data");
tmr.setInput('enableVerbose', 'true');
tmr.setInput('projectName', 'Example Project Name');
tmr.setInput('scanPath', '**/*.jar');
tmr.setInput('format', 'HTML,SARIF');
tmr.setInput('enableExperimental', 'false');
tmr.setInput('enableRetired', 'false');
tmr.setInput('uploadReports', 'true');
tmr.setInput('uploadSARIFReport', 'true');
tmr.setInput('warnOnCVSSViolation', 'true');
tmr.setInput('reportsDirectory', "data");

// provide answers for task mock
let a: ma.TaskLibAnswers = <ma.TaskLibAnswers>{};
//a.checkPath[path.join(__dirname, "data")] = true;
//a.checkPath[path.join(__dirname, "data", "dependency-check")] = true;
tr.setAnswers(a);
tmr.setAnswers(a);

tr.run();
tmr.run();
Loading

0 comments on commit 7db2124

Please sign in to comment.