Skip to content

Commit 6c5c82c

Browse files
authored
Merge pull request #1 from pohanhuangtw/NVSHAS-8744
[NVSHAS-8744] Error scanning with bamboo-plugin
2 parents 9d88929 + c351be6 commit 6c5c82c

23 files changed

+2394
-12
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,9 @@
2121

2222
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
2323
hs_err_pid*
24+
25+
.DS_Store
26+
target
27+
28+
.DS_Store
29+
target

LICENSE

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -175,18 +175,7 @@
175175

176176
END OF TERMS AND CONDITIONS
177177

178-
APPENDIX: How to apply the Apache License to your work.
179-
180-
To apply the Apache License to your work, attach the following
181-
boilerplate notice, with the fields enclosed by brackets "[]"
182-
replaced with your own identifying information. (Don't include
183-
the brackets!) The text should be enclosed in the appropriate
184-
comment syntax for the file format. We also recommend that a
185-
file or class name and description of purpose be included on the
186-
same "printed page" as the copyright notice for easier
187-
identification within third-party archives.
188-
189-
Copyright [yyyy] [name of copyright owner]
178+
Copyright 2019 NeuVector, Inc.
190179

191180
Licensed under the Apache License, Version 2.0 (the "License");
192181
you may not use this file except in compliance with the License.
@@ -199,3 +188,4 @@
199188
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200189
See the License for the specific language governing permissions and
201190
limitations under the License.
191+

README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Bamboo plugin
2+
- [Work flow](#work-flow)
3+
- [Env setup](#env-setup)
4+
- [Prerequest](#prerequest)
5+
- [Server setup](#server-setup)
6+
- [Plugin setup](#plugin-setup)
7+
- [How to run the plugin](#how-to-run-the-plugin)
8+
- [Trouble shooting](#trouble-shooting)
9+
- [Build from source](#build-from-source)
10+
- [Reference](#reference)
11+
12+
# Work flow
13+
![CI-plugin drawio](https://github.com/pohanhuangtw/bamboo-plugin/assets/145627854/a248014b-a562-45f5-ac92-a52c24091f3e)
14+
15+
16+
# Env setup
17+
## Prerequest
18+
- [Install the Atlassian SDK on a Linux or Mac system](https://developer.atlassian.com/server/framework/atlassian-sdk/install-the-atlassian-sdk-on-a-linux-or-mac-system/#install-the-atlassian-sdk-on-a-linux-or-mac-system)
19+
20+
## Server setup
21+
1. Start a bamboo server (bamboo server or you have your own)
22+
- Simply run `atlas-create-bamboo-plugin` in terminal.
23+
- Then `atlas-run`
24+
2. Go to Manage App, install it with .obr file
25+
<img width="1133" alt="Screen Shot 2024-03-15 at 4 57 46 PM" src="https://github.com/pohanhuangtw/bamboo-plugin/assets/145627854/88bc2066-445f-4e60-9205-9a4423abee52">
26+
27+
28+
## Plugin setup
29+
1. Go to Neuvector Section
30+
<img width="769" alt="Screen Shot 2024-03-15 at 5 06 28 PM" src="https://github.com/pohanhuangtw/bamboo-plugin/assets/145627854/65bfa246-c10c-4387-8966-8a983f2bf1e2">
31+
32+
2. Setup the env based on your need.
33+
<img width="1333" alt="Screen Shot 2024-03-15 at 5 09 32 PM" src="https://github.com/pohanhuangtw/bamboo-plugin/assets/145627854/355ee0eb-a193-4017-8a86-4e81dbbd276a">
34+
35+
36+
2. [Create a Project](https://www.youtube.com/watch?v=7KuNy9CD1lA&t=7s) and set up tasks.
37+
3. Set up the task based on your need
38+
- Set up the fail / exempt, write in format like **CVE-2021-23840**
39+
- Click X can dynamically delete the CVE
40+
<img width="1333" alt="Screen Shot 2024-03-15 at 5 09 32 PM" src="https://github.com/pohanhuangtw/bamboo-plugin/assets/145627854/2e7e5552-c80e-48b6-96d5-53b869d931bb">
41+
42+
43+
4. Create artifact in task, must create or you have no such report
44+
<img width="1944" alt="Screen Shot 2024-03-20 at 12 03 59 PM" src="https://github.com/pohanhuangtw/bamboo-plugin/assets/145627854/8ac4316a-482d-468f-9633-6824ce8cd638">
45+
46+
47+
48+
49+
## How to run the plugin
50+
- Click run.
51+
- When finish, we will have two files (you can click to download)
52+
- Html
53+
- Json
54+
- Txt
55+
<img width="1018" alt="Screen Shot 2024-03-20 at 12 03 44 PM" src="https://github.com/pohanhuangtw/bamboo-plugin/assets/145627854/cc73964f-78d8-49ba-86dc-872db66984f8">
56+
57+
58+
59+
# Trouble shooting
60+
1. buildLogger.addBuildLogEntry() shows in console of the task.
61+
<img width="1326" alt="Screen Shot 2024-03-15 at 5 13 23 PM" src="https://github.com/pohanhuangtw/bamboo-plugin/assets/145627854/19978663-0bd8-4801-992d-95bcbc35a881">
62+
63+
64+
2. System.out.println() shows in bamboo server, where your run `atlas-run`
65+
<img width="1186" alt="Screen Shot 2024-03-15 at 5 12 15 PM" src="https://github.com/pohanhuangtw/bamboo-plugin/assets/145627854/c8537949-8ae4-42f5-8a76-9029e5dde9ae">
66+
67+
68+
69+
# Build from source
70+
`atlas-clean && atlas-mvn package` can generate the .obr / .jar
71+
72+
# Reference
73+
1. [Create a HelloWorld plugin project](https://developer.atlassian.com/server/framework/atlassian-sdk/create-a-helloworld-plugin-project/#create-a-helloworld-plugin-project)
74+
2. [Bamboo Tutorial](https://www.youtube.com/watch?v=7KuNy9CD1lA&t=7s)

pom.xml

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
5+
6+
<modelVersion>4.0.0</modelVersion>
7+
<groupId>neuvector</groupId>
8+
<artifactId>neuvector</artifactId>
9+
<version>1.0.2-SNAPSHOT</version>
10+
11+
<organization>
12+
<name>NeuVector</name>
13+
<url>https://www.neuvector.com/</url>
14+
</organization>
15+
16+
<name>NeuVector</name>
17+
<description>This is the NeuVector image scanner plugin for Atlassian Bamboo.</description>
18+
<packaging>atlassian-plugin</packaging>
19+
20+
<properties>
21+
<bamboo.version>8.0.0</bamboo.version>
22+
<bamboo.data.version>${bamboo.version}</bamboo.data.version>
23+
<amps.version>8.0.2</amps.version>
24+
<plugin.testrunner.version>2.0.1</plugin.testrunner.version>
25+
<atlassian.spring.scanner.version>1.2.13</atlassian.spring.scanner.version>
26+
<!-- This property ensures consistency between the key in atlassian-plugin.xml and the OSGi bundle's key. -->
27+
<atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
28+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
29+
<maven.compiler.source>1.8</maven.compiler.source>
30+
<maven.compiler.target>1.8</maven.compiler.target>
31+
</properties>
32+
33+
<dependencies>
34+
<dependency>
35+
<groupId>com.atlassian.bamboo</groupId>
36+
<artifactId>atlassian-bamboo-web</artifactId>
37+
<version>${bamboo.version}</version>
38+
<scope>provided</scope>
39+
</dependency>
40+
<dependency>
41+
<groupId>com.atlassian.plugin</groupId>
42+
<artifactId>atlassian-spring-scanner-annotation</artifactId>
43+
<version>${atlassian.spring.scanner.version}</version>
44+
<scope>provided</scope>
45+
</dependency>
46+
<dependency>
47+
<groupId>javax.inject</groupId>
48+
<artifactId>javax.inject</artifactId>
49+
<version>1</version>
50+
<scope>provided</scope>
51+
</dependency>
52+
<dependency>
53+
<groupId>org.apache.httpcomponents</groupId>
54+
<artifactId>httpclient</artifactId>
55+
<version>4.5.14</version>
56+
<scope>provided</scope>
57+
</dependency>
58+
<dependency>
59+
<groupId>junit</groupId>
60+
<artifactId>junit</artifactId>
61+
<version>4.10</version>
62+
<scope>test</scope>
63+
</dependency>
64+
<!-- DEPENDENCIES TO AVOID LOADER CONFLICT-->
65+
<dependency>
66+
<groupId>org.slf4j</groupId>
67+
<artifactId>slf4j-api</artifactId>
68+
<version>1.7.30</version>
69+
<scope>provided</scope>
70+
</dependency>
71+
<!-- WIRED TEST RUNNER DEPENDENCIES -->
72+
<dependency>
73+
<groupId>com.atlassian.plugins</groupId>
74+
<artifactId>atlassian-plugins-osgi-testrunner</artifactId>
75+
<version>${plugin.testrunner.version}</version>
76+
<scope>test</scope>
77+
</dependency>
78+
<dependency>
79+
<groupId>javax.ws.rs</groupId>
80+
<artifactId>jsr311-api</artifactId>
81+
<version>1.1.1</version>
82+
<scope>provided</scope>
83+
</dependency>
84+
<dependency>
85+
<groupId>com.google.code.gson</groupId>
86+
<artifactId>gson</artifactId>
87+
<version>2.10.1</version>
88+
</dependency>
89+
<dependency>
90+
<groupId>com.github.docker-java</groupId>
91+
<artifactId>docker-java-core</artifactId>
92+
<version>3.2.12</version>
93+
</dependency>
94+
<dependency>
95+
<groupId>com.github.docker-java</groupId>
96+
<artifactId>docker-java-transport-httpclient5</artifactId>
97+
<version>3.2.12</version>
98+
</dependency>
99+
<dependency>
100+
<groupId>commons-io</groupId>
101+
<artifactId>commons-io</artifactId>
102+
<version>2.6</version> <!-- Make sure this matches across compile and runtime environments -->
103+
</dependency>
104+
</dependencies>
105+
106+
<build>
107+
<plugins>
108+
<plugin>
109+
<groupId>com.atlassian.maven.plugins</groupId>
110+
<artifactId>bamboo-maven-plugin</artifactId>
111+
<version>${amps.version}</version>
112+
<extensions>true</extensions>
113+
<configuration>
114+
<productVersion>${bamboo.version}</productVersion>
115+
<productDataVersion>${bamboo.data.version}</productDataVersion>
116+
<enableQuickReload>true</enableQuickReload>
117+
118+
<!-- See here for an explanation of default instructions: -->
119+
<!-- https://developer.atlassian.com/docs/advanced-topics/configuration-of-instructions-in-atlassian-plugins -->
120+
<instructions>
121+
<Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>
122+
123+
<!-- Add package to export here -->
124+
<Export-Package>
125+
neuvector.api,
126+
</Export-Package>
127+
128+
<!-- Add package import here -->
129+
<Import-Package>
130+
org.springframework.osgi.*;resolution:="optional",
131+
org.eclipse.gemini.blueprint.*;resolution:="optional",
132+
*;version="0";resolution:="optional"
133+
</Import-Package>
134+
135+
<!-- Ensure plugin is spring powered -->
136+
<Spring-Context>*</Spring-Context>
137+
</instructions>
138+
</configuration>
139+
</plugin>
140+
141+
<plugin>
142+
<groupId>com.atlassian.plugin</groupId>
143+
<artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
144+
<version>${atlassian.spring.scanner.version}</version>
145+
<executions>
146+
<execution>
147+
<goals>
148+
<goal>atlassian-spring-scanner</goal>
149+
</goals>
150+
<phase>process-classes</phase>
151+
</execution>
152+
</executions>
153+
<configuration>
154+
<scannedDependencies>
155+
<dependency>
156+
<groupId>com.atlassian.plugin</groupId>
157+
<artifactId>atlassian-spring-scanner-external-jar</artifactId>
158+
</dependency>
159+
</scannedDependencies>
160+
<verbose>false</verbose>
161+
</configuration>
162+
</plugin>
163+
</plugins>
164+
</build>
165+
166+
<repositories>
167+
<repository>
168+
<id>atlassian-public</id>
169+
<url>https://packages.atlassian.com/maven/repository/public/</url>
170+
<releases>
171+
<enabled>true</enabled>
172+
</releases>
173+
<snapshots>
174+
<enabled>true</enabled>
175+
</snapshots>
176+
</repository>
177+
</repositories>
178+
179+
</project>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package neuvector;
2+
3+
import com.atlassian.spring.container.ContainerManager;
4+
import com.atlassian.bamboo.configuration.AdministrationConfiguration;
5+
import org.apache.commons.lang.StringUtils;
6+
7+
public abstract class AdminConfigUtil
8+
{
9+
private static AdministrationConfiguration adminConfig;
10+
11+
public static String getAdminConfig(final String key) {
12+
if (AdminConfigUtil.adminConfig == null) {
13+
AdminConfigUtil.adminConfig = (AdministrationConfiguration) ContainerManager.getComponent("administrationConfiguration");
14+
}
15+
return StringUtils.defaultString(AdminConfigUtil.adminConfig.getSystemProperty(key));
16+
}
17+
}

0 commit comments

Comments
 (0)