Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Maven project support #9

Merged
merged 1 commit into from
Dec 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,29 @@ This is a tool which injects a Java agent into a running JVM process. The agent
This has been currently only tested with JDK 8, 11, 15 and 17 on Linux!

## Building
### Gradle
To build on linux, mac and Windows subsystem for linux
```
./gradlew build
```

To build on Windows
```
.\gradlew.bat build
```

Depending on the platform you are building. This will generate `build/libs/Log4jHotPatch.jar`

### Maven

To build using Maven use

```
mvn clean package
```

This will generate a `target/Log4jHotPatch.jar`.

## Running

JDK 8
Expand All @@ -35,9 +48,9 @@ java -classpath <class-path> -javaagent:Log4jHotPatch.jar <main-class> <argument
```

### Testing the agent
There are a set of tests that can be run outside gradle.
There are a set of tests that can be run outside Gradle or Maven.
```
build-tools/bin/run_tests.sh build/libs/Log4jHotPatch.jar <JDK_ROOT>
build-tools/bin/run_tests.sh Log4jHotPatch.jar <JDK_ROOT>
```

## Known issues
Expand Down
132 changes: 132 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
<?xml version="1.0"?>
<!--
~ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
~
~ Licensed under the Apache License, Version 2.0 (the "License").
~ You may not use this file except in compliance with the License.
~ A copy of the License is located at
~
~ http://aws.amazon.com/apache2.0
~
~ or in the "license" file accompanying this file. This file 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.
-->

<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.amazon.corretto.hotpatch</groupId>
<artifactId>hotpatch-for-apache-log4j2</artifactId>
<version>1.3</version>
<packaging>jar</packaging>
<name>Hotpatch for Apache Log4j2</name>
<description>A hotpatch to address CVE-2021-44228.</description>

<url>https://aws.amazon.com/corretto</url>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>https://aws.amazon.com/apache2.0</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<id>amazonwebservices</id>
<organization>Amazon Web Services</organization>
<organizationUrl>https://aws.amazon.com</organizationUrl>
<roles>
<role>developer</role>
</roles>
</developer>
</developers>

<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
<nexus-staging-maven-plugin.version>1.6.8</nexus-staging-maven-plugin.version>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<profiles>
<profile>
<id>jdk8</id>
<activation>
<jdk>1.8</jdk>
</activation>
<dependencies>
<dependency>
<groupId>jdk.tools</groupId>
<artifactId>jdk.tools</artifactId>
<version>jdk1.8.0</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
</profile>
<profile>
<id>publishing</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>${maven-gpg-plugin.version}</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>${nexus-staging-maven-plugin.version}</version>
<extensions>true</extensions>
<configuration>
<serverId>sonatype-nexus-staging</serverId>
<nexusUrl>https://aws.oss.sonatype.org</nexusUrl>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>


<build>
<finalName>Log4jHotPatch</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
<configuration>
<archive>
<manifestEntries>
<Implementation-Version>${project.version}</Implementation-Version>
<Implementation-Title>Log4jHotPatch</Implementation-Title>
<Implementation-Vendor>Amazon Corretto Team</Implementation-Vendor>
<Created-by>Amazon Corretto Team</Created-by>
<Agent-Class>Log4jHotPatch</Agent-Class>
<Premain-Class>Log4jHotPatch</Premain-Class>
<Main-Class>Log4jHotPatch</Main-Class>
<Can-Redefine-Classes>true</Can-Redefine-Classes>
<Can-Retransform-Classes>true</Can-Retransform-Classes>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>

</project>