-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Zvi Grinberg <[email protected]>
- Loading branch information
1 parent
de8d1cb
commit e85ab07
Showing
9 changed files
with
373 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import fs from "node:fs"; | ||
import {AnalysisReport} from '../../generated/backend/AnalysisReport.js' | ||
import index from "../../src/index.js" | ||
import { expect } from 'chai' | ||
// import fs from 'node:fs' | ||
|
||
function getManifestNamePerPm(packageManager) { | ||
return packageManagersDict[packageManager]; | ||
} | ||
|
||
const packageManagersDict = | ||
{ | ||
"maven" : "pom.xml", | ||
"npm" : "package.json", | ||
"go" : "go.mod", | ||
"pip" : "requirements.txt" | ||
} | ||
|
||
function getParsedSummaryFromHtml(html) { | ||
return JSON.parse(html.substring(html.indexOf("\"summary\"") + 10,html.indexOf("\"}]}") + 4)); | ||
} | ||
|
||
suite('Integration Tests', () => { | ||
// let opts = { | ||
// EXHORT_DEV_MODE: "true", | ||
// EXHORT_SNYK_TOKEN: "ee64316c-a4ba-4ca0-a785-18cb05ed3f25" | ||
// | ||
// } | ||
["maven", | ||
"npm", | ||
"go", | ||
"pip" | ||
].forEach(packageManager => { | ||
test(`Stack Analysis json for ${packageManager}`, async () => { | ||
// process.env["EXHORT_DEBUG"]= "true" | ||
// process.env["EXHORT_DEV_MODE"]= "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" | ||
// let result = await index.stackAnalysis("/tmp/rajan-0410/go.mod", false, opts); | ||
if(packageManager === "pip") | ||
{ | ||
process.env["EXHORT_PYTHON_VIRTUAL_ENV"] = "true" | ||
} | ||
else | ||
{ | ||
process.env["EXHORT_PYTHON_VIRTUAL_ENV"] = "" | ||
} | ||
let manifestName = getManifestNamePerPm(packageManager) | ||
let pomPath = `test/it/test_manifests/${packageManager}/${manifestName}` | ||
let providedDataForStack = await index.stackAnalysis(pomPath) | ||
console.log(JSON.stringify(providedDataForStack.summary,null , 4)) | ||
expect(providedDataForStack.summary.dependencies.scanned).greaterThan(0) | ||
// python transitive count for stack analysis is awaiting fix in exhort backend | ||
if(packageManager !== "pip") | ||
{ | ||
expect(providedDataForStack.summary.dependencies.transitive).greaterThan(0) | ||
} | ||
expect(providedDataForStack.summary.vulnerabilities.total).greaterThanOrEqual(0) | ||
providedDataForStack.summary.providerStatuses.forEach(provider => expect(provider.status).equals(200)) | ||
}).timeout(15000); | ||
|
||
test(`Stack Analysis html for ${packageManager}`, async () => { | ||
let manifestName = getManifestNamePerPm(packageManager) | ||
let pomPath = `test/it/test_manifests/${packageManager}/${manifestName}` | ||
let html = await index.stackAnalysis(pomPath,true) | ||
if(packageManager === "pip") | ||
{ | ||
process.env["EXHORT_PYTHON_VIRTUAL_ENV"] = "true" | ||
} | ||
else | ||
{ | ||
process.env["EXHORT_PYTHON_VIRTUAL_ENV"] = "" | ||
} | ||
let parsedSummaryFromHtml = getParsedSummaryFromHtml(html); | ||
expect( typeof html).equals("string") | ||
expect(html).include("html").include("svg") | ||
expect(parsedSummaryFromHtml.dependencies.scanned).greaterThan(0) | ||
// python transitive count for stack analysis is awaiting fix in exhort backend | ||
if(packageManager !== "pip") | ||
{ | ||
expect(parsedSummaryFromHtml.dependencies.transitive).greaterThan(0) | ||
} | ||
expect(parsedSummaryFromHtml.vulnerabilities.total).greaterThanOrEqual(0) | ||
parsedSummaryFromHtml.providerStatuses.forEach(provider => expect(provider.status).equals(200)) | ||
}).timeout(15000); | ||
|
||
test(`Component Analysis for ${packageManager}`, async () => { | ||
let manifestName = getManifestNamePerPm(packageManager) | ||
let pomPath = `test/it/test_manifests/${packageManager}/${manifestName}` | ||
let analysisReport = await index.componentAnalysis(manifestName,fs.readFileSync(pomPath).toString()) | ||
|
||
expect(analysisReport.summary.dependencies.scanned).greaterThan(0) | ||
expect(analysisReport.summary.dependencies.transitive).equal(0) | ||
expect(analysisReport.summary.vulnerabilities.total).greaterThanOrEqual(0) | ||
analysisReport.summary.providerStatuses.forEach(provider => expect(provider.status).equals(200)) | ||
}).timeout(10000); | ||
|
||
|
||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module github.com/test-golang-namespace/test-golang-app | ||
|
||
go 1.19 | ||
|
||
require( | ||
|
||
github.com/gin-gonic/gin v1.6.0 | ||
github.com/ipld/go-car v0.3.0 | ||
go.elastic.co/apm v1.11.0 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>pom-with-deps-no-ignore</groupId> | ||
<artifactId>pom-with-dependency-not-ignored-for-tests</artifactId> | ||
<version>0.0.1</version> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>log4j</groupId> | ||
<artifactId>log4j</artifactId> | ||
<version>1.2.17</version> | ||
</dependency> | ||
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok --> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<version>1.16.6</version> | ||
</dependency> | ||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind --> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-databind</artifactId> | ||
<version>2.14.0</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
Oops, something went wrong.