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
8 changes: 4 additions & 4 deletions integration/run_its.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ fi
StatusCodeTC=$(jq '.providers["trusted-content"].status.code' ./responses/stack.json)
matchConstant "200" "$StatusCodeTC" "Check that Response code from Trusted Content is OK ( Http Status = 200)..."

StatusCodeSnyk=$(jq '.providers.snyk.status.code' ./responses/stack.json)
matchConstant "200" "$StatusCodeSnyk" "Check that Response code from Snyk Provider is OK ( Http Status = 200)..."
#StatusCodeSnyk=$(jq '.providers.snyk.status.code' ./responses/stack.json)
#matchConstant "200" "$StatusCodeSnyk" "Check that Response code from Snyk Provider is OK ( Http Status = 200)..."

echo "RUNNING JavaScript CLI integration test for Component Analysis report for Java Maven"
eval "testers/cli/node_modules/.bin/exhort-javascript-api component pom.xml '$(<scenarios/maven/pom.xml)'" > ./responses/component.json
Expand All @@ -156,8 +156,8 @@ fi

StatusCodeTC=$(jq '.providers["trusted-content"].status.code' ./responses/stack.json)
matchConstant "200" "$StatusCodeTC" "Check that Response code from Trusted Content is OK ( Http Status = 200)..."
StatusCodeSnyk=$(jq '.providers.snyk.status.code' ./responses/stack.json)
matchConstant "200" "$StatusCodeSnyk" "Check that Response code from Snyk Provider is OK ( Http Status = 200)..."
#StatusCodeSnyk=$(jq '.providers.snyk.status.code' ./responses/stack.json)
#matchConstant "200" "$StatusCodeSnyk" "Check that Response code from Snyk Provider is OK ( Http Status = 200)..."

echo "RUNNING JavaScript CLI integration test for Validate Token Function With wrong token, expecting getting 401 http status code "
answerAboutToken=$(testers/cli/node_modules/.bin/exhort-javascript-api validate-token snyk --value=veryBadTokenValue)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"src/providers/java_maven.js",
"src/providers/javascript_npm.js"
],
"lines": 83,
"lines": 82,
"reporter": [
"html",
"json",
Expand Down
12 changes: 8 additions & 4 deletions src/providers/python_pip.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ function handlePythonEnvironment(binaries, opts) {
return createVirtualPythonEnv
}

const DEFAULT_PIP_ROOT_COMPONENT_NAME = "default-pip-root";

const DEFAULT_PIP_ROOT_COMPONENT_VERSION = "0.0.0";

/**
* Create sbom json string out of a manifest path for stack analysis.
* @param {string} manifest - path for requirements.txt
Expand All @@ -206,14 +210,14 @@ function createSbomStackAnalysis(manifest, opts = {}) {
let pythonController = new Python_controller(createVirtualPythonEnv === "false",binaries.pip,binaries.python,manifest,opts)
let dependencies = pythonController.getDependencies(true);
let sbom = new Sbom();
sbom.addRoot(toPurl("root",undefined))
sbom.addRoot(toPurl(DEFAULT_PIP_ROOT_COMPONENT_NAME,DEFAULT_PIP_ROOT_COMPONENT_VERSION))
dependencies.forEach(dep => {
addAllDependencies(sbom.getRoot(),dep,sbom)
})
let requirementTxtContent = fs.readFileSync(manifest).toString();
handleIgnoredDependencies(requirementTxtContent,sbom,opts)
// In python there is no root component, then we must remove the dummy root we added, so the sbom json will be accepted by exhort backend
sbom.removeRootComponent()
// sbom.removeRootComponent()
return sbom.getAsJsonString()


Expand All @@ -236,14 +240,14 @@ function getSbomForComponentAnalysis(data, opts = {}) {
let pythonController = new Python_controller(createVirtualPythonEnv === "false",binaries.pip,binaries.python,tmpRequirementsPath,opts)
let dependencies = pythonController.getDependencies(false);
let sbom = new Sbom();
sbom.addRoot(toPurl("root",undefined))
sbom.addRoot(toPurl(DEFAULT_PIP_ROOT_COMPONENT_NAME,DEFAULT_PIP_ROOT_COMPONENT_VERSION))
dependencies.forEach(dep => {
sbom.addDependency(sbom.getRoot(),toPurl(dep.name, dep.version))
})
fs.rmSync(tmpDir, { recursive: true, force: true });
handleIgnoredDependencies(data,sbom,opts)
// In python there is no root component, then we must remove the dummy root we added, so the sbom json will be accepted by exhort backend
sbom.removeRootComponent()
// sbom.removeRootComponent()
return sbom.getAsJsonString()
}

Expand Down
17 changes: 9 additions & 8 deletions test/it/end-to-end.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,11 @@ suite('Integration Tests', () => {
// EXHORT_DEV_MODE: "true",
//
// }

//
// test(`Stack Analysis json`, async () => {
// process.env["EXHORT_DEBUG"]= "true"
// process.env["EXHORT_DEV_MODE"]= "true"
// process.env["EXHORT_DEV_MODE"]= "false"
// process.env["MATCH_MANIFEST_VERSIONS"]= "false"
// // process.env["EXHORT_GO_PATH"]= "/home/zgrinber/test-go/go/bin/go"
// // process.env["RHDA_TOKEN"] = "34JKLDS-4234809-66666666666"
// // process.env["RHDA_SOURCE"] = "Zvika Client"
Expand All @@ -128,20 +129,20 @@ suite('Integration Tests', () => {
// EXHORT_OSS_INDEX_USER: 'zgrinber@redhat.com',
// EXHORT_GO_MVS_LOGIC_ENABLED: 'true'
// }
// process.env["EXHORT_PYTHON_VIRTUAL_ENV"] = "true"
// process.env["EXHORT_PYTHON_INSTALL_BEST_EFFORTS"] = "true"
// process.env["EXHORT_PYTHON_VIRTUAL_ENV"] = "fasle"
// process.env["EXHORT_PYTHON_INSTALL_BEST_EFFORTS"] = "false"
// process.env["MATCH_MANIFEST_VERSIONS"] = "false"
// // let pomPath = `/tmp/070324/package.json`
// let pomPath = `/tmp/170324/requirements.txt`
// let pomPath = `/tmp/requirements.txt`
// // let pomPath = `/home/zgrinber/git/tracing-demos-and-examples/tracing-parent/pom.xml`
// let providedDataForStack;
// // providedDataForStack = await index.componentAnalysis("requirements.txt", fs.readFileSync(pomPath).toString(),{},pomPath);
// providedDataForStack = await index.stackAnalysis(pomPath);
// providedDataForStack = await index.stackAnalysis(pomPath,true);
// // console.log(JSON.stringify(providedDataForStack,null , 4))
// // fs.writeFileSync(`/tmp/301123/report.html`,providedDataForStack)
// fs.writeFileSync(`/tmp/report.html`,providedDataForStack)
//
// // expect(providedDataForStack.summary.dependencies.scanned).greaterThan(0)
// }).timeout(15000);
// }).timeout(30000);
//
//
//
Expand Down
2 changes: 1 addition & 1 deletion test/providers/python_pip.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {getCustomPath } from "../../src/tools.js"
let clock

async function sharedComponentAnalysisTestFlow(testCase,usePipDepTreeUtility) {
// load the expected list for the scenario
// load the expected list for tsharedComponentAnalysisTestFlowhe scenario
let expectedSbom = fs.readFileSync(`test/providers/tst_manifests/pip/${testCase}/expected_component_sbom.json`,).toString().trim()
expectedSbom = JSON.stringify(JSON.parse(expectedSbom))
// read target manifest file
Expand Down
Loading