Giter VIP home page Giter VIP logo

Comments (1)

tamasmak avatar tamasmak commented on August 24, 2024

In the cyclonedx-maven-plugin configuration we can set the outputDirectory for the generated SBOM.

If we set this to

<plugin>
	<groupId>org.cyclonedx</groupId>
	<artifactId>cyclonedx-maven-plugin</artifactId>
	<version>2.7.7</version>
	<executions>
		<execution>
			<phase>prepare-package</phase>
			<goals>
				<goal>makeAggregateBom</goal>
			</goals>
		</execution>
	</executions>
	<configuration>
		...
		<outputFormat>json</outputFormat>
		<outputName>bom</outputName>
		<outputDirectory>${project.build.directory}/generated-resources/bom</outputDirectory>
		...
	</configuration>
</plugin>

then the generated SBOM json file will be included in the target/generated-resource/bom directory.

After, using the maven-resources-plugin we can copy this SBOM file to the project's output directory like this

<plugin>
	<artifactId>maven-resources-plugin</artifactId>
	<version>3.2.0</version>
	<executions>
		<execution>
			<id>copy-bom</id>
			<phase>prepare-package</phase>
			<goals>
				<goal>copy-resources</goal>
			</goals>
			<configuration>
				<outputDirectory>${project.build.outputDirectory}/resources</outputDirectory>
				<resources>
					<resource>
						<directory>${project.build.directory}/generated-resources/bom</directory>
						<filtering>false</filtering>
					</resource>
				</resources>
			</configuration>
		</execution>
	</executions>
</plugin>

This will include the SBOM file during the prepare-package phase into the packed project under the resources directory. This plugin should be placed after the cyclonedx-maven-plugin because the SBOM generation will also happen in the prepare-package phase.

With this solution we could get the SBOM resource during runtime.

I created an example for this solution (3bda98, cdb796) in the cyclonedx-sbom branch.
In the example I used the cyclonedx-core-java dependency to parse the SBOM file and to use the predefined data models.

<dependency>
	<groupId>org.cyclonedx</groupId>
	<artifactId>cyclonedx-core-java</artifactId>
	<version>7.3.2</version>
</dependency>

I added the BOMServiceInitListener where the SBOM parsing happens and added the BOMService to store the SBOM model. Also added a grid component to the DemoUI just to represent the usage of this dependency.

from appsec-kit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.