-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: CycloneDX Inhouse Implementation (#160)
💥
- Loading branch information
1 parent
f596340
commit 2c0d2b5
Showing
16 changed files
with
551 additions
and
49 deletions.
There are no files selected for viewing
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,62 @@ | ||
/* | ||
* Copyright (c) 2019-present Sonatype, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { CycloneDXSbomCreator } from './CycloneDXSbomCreator'; | ||
import expect from '../Tests/TestHelper'; | ||
|
||
// Test object with circular dependency, scoped dependency, dependency with dependency | ||
const object = { | ||
'name': 'testproject', | ||
'version': '1.0.0', | ||
'description': 'Test Description', | ||
'dependencies': { | ||
'testdependency': { | ||
'name': 'testdependency', | ||
'version': '1.0.1', | ||
'dependencies': { | ||
'testdependency': { | ||
'name': 'testdependency', | ||
'version': '1.0.1', | ||
} | ||
} | ||
}, | ||
'testdependency2': { | ||
'name': 'testdependency2', | ||
'version': '1.0.2', | ||
'dependencies': { | ||
'testdependency': { | ||
'name': 'testdependency', | ||
'version': '1.0.0', | ||
} | ||
} | ||
}, | ||
'@scope/testdependency3': { | ||
'name': '@scope/testdependency3', | ||
'version': '1.0.2' | ||
} | ||
} | ||
} | ||
|
||
const expectedResponse = `<?xml version="1.0" encoding="utf-8"?><bom xmlns="http://cyclonedx.org/schema/bom/1.1" version="1"><components><component type="library" bom-ref="pkg:npm/[email protected]"><name>testdependency</name><version>1.0.1</version><description/><purl>pkg:npm/[email protected]</purl></component><component type="library" bom-ref="pkg:npm/[email protected]"><name>testdependency2</name><version>1.0.2</version><description/><purl>pkg:npm/[email protected]</purl></component><component type="library" bom-ref="pkg:npm/[email protected]"><name>testdependency</name><version>1.0.0</version><description/><purl>pkg:npm/[email protected]</purl></component><component type="library" bom-ref="pkg:npm/%40scope/[email protected]"><group>@scope</group><name>testdependency3</name><version>1.0.2</version><description/><purl>pkg:npm/%40scope/[email protected]</purl></component></components></bom>`; | ||
|
||
describe("CycloneDXSbomCreator", async () => { | ||
it("should create an sbom string given a minimal valid object", async () => { | ||
let sbomCreator = new CycloneDXSbomCreator(process.cwd()); | ||
|
||
let string = await sbomCreator.createBom(object); | ||
|
||
expect(string).to.eq(expectedResponse); | ||
}); | ||
}); |
Oops, something went wrong.