Skip to content

Commit

Permalink
tweak shading
Browse files Browse the repository at this point in the history
  • Loading branch information
planetlevel committed Dec 28, 2021
1 parent 0f0bbc3 commit dfec78e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.DS_Store
.vscode/
dependency-reduced-pom.xml
sbom.json
7 changes: 2 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@
<configuration>
<relocations>
<relocation>
<pattern>com.contrastsecurity</pattern>
<shadedPattern>com.contrastsecurity</shadedPattern>
<pattern>com.fasterxml</pattern>
<shadedPattern>com.contrastsecurity.shaded.com.fasterxml</shadedPattern>
</relocation>
<relocation>
<pattern>net</pattern>
Expand All @@ -83,9 +83,6 @@
<relocation>
<pattern>org</pattern>
<shadedPattern>com.contrastsecurity.shaded.org</shadedPattern>
<excludes>
<exclude>org.apache.logging.**.*</exclude>
</excludes>
</relocation>
</relocations>
<transformers>
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/contrastsecurity/CycloneDXModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public static Metadata makeMetadata() {
Tool jbom = new Tool();
jbom.setName("jbom - https://github.com/Contrast-Security-OSS/jbom");
jbom.setVendor("Contrast Security - https://contrastsecurity.com");
jbom.setVersion("1.0.0");
meta.setTools( new ArrayList<>(Arrays.asList(jbom)) );

String description = "Java";
Expand Down
24 changes: 14 additions & 10 deletions src/main/java/com/contrastsecurity/Jbom.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ public static void transform(String args, Instrumentation inst) {
}
agentRunning = true;

Logger.log( " _ __" );
Logger.log( " (_) /_ ____ ____ ___" );
Logger.log( " / / __ \\/ __ \\/ __ `__ \\" );
Logger.log( " / / /_/ / /_/ / / / / / /" );
Logger.log( " __/ /_.___/\\____/_/ /_/ /_/" );
Logger.log( " /___/" );
Logger.log( " by Contrast Security - https://contrastsecurity.com" );
Logger.log( " _ __" );
Logger.log( " (_) /_ ____ ____ ___" );
Logger.log( " / / __ \\/ __ \\/ __ `__ \\" );
Logger.log( " / / /_/ / /_/ / / / / / /" );
Logger.log( " __/ /_.___/\\____/_/ /_/ /_/" );
Logger.log( " /___/" );
Logger.log( " by Contrast Security - https://contrastsecurity.com" );
Logger.log( "" );
Logger.log( "jbom generates a Software Bill of Materials (SBOM) from a running JVM" );
Logger.log( " https://github.com/Contrast-Security-OSS/jbom" );
Logger.log( " jbom generates a Software Bill of Materials (SBOM) for apps on a running JVM" );
Logger.log( " https://github.com/Contrast-Security-OSS/jbom" );
Logger.log( "" );

new AgentBuilder.Default()
Expand All @@ -71,6 +71,7 @@ public Builder<?> transform(Builder<?> builder, TypeDescription typeDescription,
.installOn(inst);

reportResults( filename );

}


Expand All @@ -89,7 +90,10 @@ public void run() {
Logger.log("Writing SBOM with " + Libraries.getLibraries().size() + " libraries");
CycloneDXModel sbom = new CycloneDXModel();
sbom.setComponents( Libraries.getLibraries() );
sbom.save( filename );
sbom.save( filename );

agentRunning = false;

}
};
new Thread(thread).start();
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/com/contrastsecurity/Libraries.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
public class Libraries {

private static Set<Component> invoked = new HashSet<Component>();
private static Set<String> addedAll = new HashSet<String>();
private static Set<Component> libraries = new TreeSet<Component>();
private static Set<String> codesourceExamined = new HashSet<String>();
private static Set<Component> libraries = new HashSet<Component>();

public static void main( String[] args ) throws Exception {
String url1 = "jar:file:/Users/jeffwilliams/Downloads/log4j%20demo/myproject-0.0.1-SNAPSHOT.jar!/BOOT-INF/lib/log4j-api-2.14.1.jar!/";
Expand All @@ -49,14 +49,17 @@ public static void main( String[] args ) throws Exception {
// find containing jar file and include ALL libraries
public static void addAllLibraries( String codesource ) {

if ( addedAll.contains( codesource ) ) {
if ( codesourceExamined.contains( codesource ) ) {
return;
}

codesourceExamined.add( codesource );

if ( !isArchive( codesource ) ) {
return;
}

System.out.println( "SCANNING: " + codesource );

try {
// save this lib
String decoded = URLDecoder.decode( codesource, "UTF-8" );
Expand Down Expand Up @@ -99,7 +102,6 @@ public static void addAllLibraries( String codesource ) {
Logger.log( " CodeSource: " + codesource );
e.printStackTrace();
}
addedAll.add( codesource );
}

public static void scan( JarFile jarFile, JarInputStream jis, String codesource ) throws Exception {
Expand Down

0 comments on commit dfec78e

Please sign in to comment.