Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into 229-set-java-17-as-ne…
Browse files Browse the repository at this point in the history
…w-baseline
  • Loading branch information
casid committed May 28, 2023
2 parents a811699 + a12a0c4 commit 8efb2f7
Show file tree
Hide file tree
Showing 81 changed files with 2,518 additions and 320 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/graalvm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,5 @@ jobs:
MAVEN_OPTS: -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
- name: Build Gradle Plugin
run: cd jte-gradle-plugin && ./gradlew publishToMavenLocal
- name: Test Gradle Plugin Generate (old style)
run: cd test/jte-runtime-cp-test-gradle && ./gradlew check nativeTest
- name: Test Gradle Plugin Generate with conventions
run: cd test/jte-runtime-cp-test-gradle-convention && ./gradlew check nativeTest
4 changes: 2 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ currently being supported with security updates.

If you believe that you have found a vulnerability in jte, first please search the GitHub issues list (for both open and closed issues) to see if it has already been reported.

If it has not, then please contact Andreas Hager (andy at mazebert.com) directly. Please do not report any suspected vulnerabilities via GitHub issues as we wish to keep our users secure while a patch is implemented and deployed. This is because if this is reported as a GitHub issue, it more or less is equivalent to dropping a 0-day on all applications using jte. Instead, we encourage responsible disclosure.
If it has not, then please create a [private security advisory](https://github.com/casid/jte/security/advisories). Please do not report any suspected vulnerabilities via GitHub issues as we wish to keep our users secure while a patch is implemented and deployed. This is because if this is reported as a GitHub issue, it more or less is equivalent to dropping a 0-day on all applications using jte. Instead, we encourage responsible disclosure.

If you wish to be acknowledged for finding the vulnerability, then please follow this process. Andreas will try to contact you within at least 5 business days, so when you post the email describing the vulnerability, please do so from an email address that you usually monitor. If you eventually wish to have it published as a CVE, we will also work with you to ensure that you are given proper credit with MITRE and NIST. Even if you do not wish to report the vulnerability as a CVE, we will acknowledge you when we create a GitHub issue (once the issue is patched) as well as acknowledging you in any security bulletin that we may write up and use to notify our users. (If you wish to have your identity remain unknown, or perhaps you email address, we can work with you on that as well.)
If you wish to be acknowledged for finding the vulnerability, then please follow this process. We will try to contact you within at least 5 business days. If you eventually wish to have it published as a CVE, we will also work with you to ensure that you are given proper credit with MITRE and NIST. Even if you do not wish to report the vulnerability as a CVE, we will acknowledge you in the patch notes as well as acknowledging you in any security bulletin that we may write up and use to notify our users. (If you wish to have your identity remain unknown, we can work with you on that as well.)

If possible, provide a working proof-of-concept or at least minimally describe how it can be exploited in sufficient details that we can understand what needs to be done to fix it. Unfortunately at this time, we are not in a position to pay out bug bounties for vulnerabilities.
45 changes: 45 additions & 0 deletions jte-extension-api-mocks/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>gg.jte</groupId>
<artifactId>jte-parent</artifactId>
<version>2.3.3-SNAPSHOT</version>
</parent>

<artifactId>jte-extension-api-mocks</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>gg.jte</groupId>
<artifactId>jte-extension-api</artifactId>
<version>2.3.3-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>gg.jte</groupId>
<artifactId>jte-runtime</artifactId>
<version>2.3.3-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>gg.jte.extension.api.mocks</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package gg.jte.extension;

import gg.jte.ContentType;

import java.nio.file.Path;

/**
* Mock implementation to help with testing extensions.
*/
public class MockConfig implements JteConfig {
Path generatedSourcesRoot;
Path generatedResourcesRoot;
String projectNamespace;
String packageName;
ContentType contentType;

public static MockConfig mockConfig() {
return new MockConfig();
}

public MockConfig generatedSourcesRoot(Path value) {
generatedSourcesRoot = value;
return this;
}

public MockConfig generatedResourcesRoot(Path value) {
generatedResourcesRoot = value;
return this;
}

public MockConfig projectNamespace(String value) {
projectNamespace = value;
return this;
}

public MockConfig packageName(String value) {
packageName = value;
return this;
}

public MockConfig contentType(ContentType value) {
contentType = value;
return this;
}

@Override
public Path generatedSourcesRoot() {
return generatedSourcesRoot;
}

@Override
public Path generatedResourcesRoot() {
return generatedResourcesRoot;
}

@Override
public String projectNamespace() {
return projectNamespace;
}

@Override
public String packageName() {
return packageName;
}

@Override
public ContentType contentType() {
return contentType;
}

@Override
public ClassLoader classLoader() {
return getClass().getClassLoader();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package gg.jte.extension;

/**
* Mock implementation to help with testing extensions.
*/
public class MockParamDescription implements ParamDescription {
String type;
String name;
String defaultValue;

public static MockParamDescription mockParamDescription() {
return new MockParamDescription();
}

public MockParamDescription type(String value) {
type = value;
return this;
}

public MockParamDescription name(String value) {
name = value;
return this;
}

public MockParamDescription defaultValue(String value) {
defaultValue = value;
return this;
}

@Override
public String type() {
return type;
}

@Override
public String name() {
return name;
}

@Override
public String defaultValue() {
return defaultValue;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package gg.jte.extension;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
* Mock implementation to help with testing extensions.
*/
public class MockTemplateDescription implements TemplateDescription {
String name;
String packageName;
String className;
List<ParamDescription> params = new ArrayList<>();
private final List<String> imports = new ArrayList<>();

public static MockTemplateDescription mockTemplateDescription() {
return new MockTemplateDescription();
}

public MockTemplateDescription name(String value) {
name = value;
return this;
}

public MockTemplateDescription packageName(String value) {
packageName = value;
return this;
}

public MockTemplateDescription className(String value) {
className = value;
return this;
}

public MockTemplateDescription params(List<ParamDescription> value) {
params.clear();
params.addAll(value);
return this;
}

public MockTemplateDescription addParams(ParamDescription... value) {
params.addAll(Arrays.asList(value));
return this;
}

public MockTemplateDescription imports(List<String> value) {
imports.clear();
imports.addAll(value);
return this;
}

public MockTemplateDescription addImports(String... value) {
imports.addAll(Arrays.asList(value));
return this;
}

@Override
public String name() {
return name;
}

@Override
public String packageName() {
return packageName;
}

@Override
public String className() {
return className;
}

@Override
public List<ParamDescription> params() {
return params;
}

@Override
public List<String> imports() {
return imports;
}
}
38 changes: 38 additions & 0 deletions jte-extension-api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
23 changes: 23 additions & 0 deletions jte-extension-api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# jte-extension-api

This module defines the interface to add extensions to jte generation.
Extensions can generate additional files based on metadata about jte templates.

## Writing an Extension

Extension authors must implement the `JteExtension` interface.
The implementing class must have a no-argument constructor so that it can be instantiated by name.

## Testing

The companion module jte-extension-api-mocks provides mock implementations of the API interfaces to help with writing unit tests.

## Usage

The jte Maven and Gradle plugins allow configuring extensions.

## Examples

* jte-models module is an extension that generates typesafe facades for templates.
* test/jte-runtime-cp-test-models uses the Maven plugin to apply the jte-models extension.
* test/jte-runtime-cp-test-models-gradle uses the Gradle plugin to apply the jte-models extension.
39 changes: 39 additions & 0 deletions jte-extension-api/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>gg.jte</groupId>
<artifactId>jte-parent</artifactId>
<version>2.3.3-SNAPSHOT</version>
</parent>

<artifactId>jte-extension-api</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>gg.jte</groupId>
<artifactId>jte-runtime</artifactId>
<version>2.3.3-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>gg.jte.extension.api</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>

</project>
21 changes: 21 additions & 0 deletions jte-extension-api/src/main/java/gg/jte/extension/JteConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package gg.jte.extension;

import gg.jte.ContentType;

import java.nio.file.Path;

/**
* An instance of this type will be given to an extension, so that it can access configuration of the jte compiler.
*/
public interface JteConfig {
Path generatedSourcesRoot();
Path generatedResourcesRoot();

String projectNamespace();

String packageName();

ContentType contentType();

ClassLoader classLoader();
}
Loading

0 comments on commit 8efb2f7

Please sign in to comment.