Skip to content
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
4 changes: 2 additions & 2 deletions .github/workflows/cf_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ jobs:
distribution: 'temurin'
cache: 'maven'
- name: Build agent
run: mvn package -U -B -pl agent --also-make -DskipTests
run: make package-agent
- name: Run CF Tests
run: mvn verify -U -B -P cf-it-tests -pl it-tests/cf-tests --also-make
run: make cf-tests
8 changes: 4 additions & 4 deletions .github/workflows/on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
cache: 'maven'

- name: Run tests
run: mvn -U -B clean verify
run: make test

# Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
- name: Update dependency graph
Expand All @@ -39,7 +39,7 @@ jobs:
distribution: 'temurin'
cache: 'maven'
- name: Check Formatting
run: mvn -U -B validate -Plint,examples,cf-it-tests
run: make lint

pmd:
runs-on: ubuntu-latest
Expand All @@ -53,7 +53,7 @@ jobs:
distribution: 'temurin'
cache: 'maven'
- name: Run PMD check
run: mvn -U -B verify -Ppmd
run: make pmd


docs:
Expand All @@ -68,5 +68,5 @@ jobs:
distribution: 'temurin'
cache: 'maven'
- name: Run docs check
run: mvn -s .ci-settings.xml clean package javadoc:jar -DskipTests -P release-ossrh -B -U -pl agent,deep --also-make
run: make docs

6 changes: 6 additions & 0 deletions .idea/google-java-format.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/kubernetes-settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions .idea/runConfigurations/VisitorTest.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .sdkmanrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Enable auto-env through the sdkman_auto_env config
# Add key=value pairs of SDKs to use below
java=13.0.2-open
26 changes: 26 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Development

Here we have a few hints on how to develop this module.

## Environment

### Java SDK

To set up the java environment we recommend using [SDKMAN](https://sdkman.io/). Once sdkman is installed simply run `sdk env` in the project
root to set the JDK.

### Building

To simplify the building the maven build is split into a few profiles to reduce the build time. There are a few commands in
the [`Makefile`](./Makefile) that can help with the builds.

## CF Debugging

To debug in CF I found the easiest way is to use the docker. We can do this with this command:

```bash
docker run --name cf_2018 --rm -p 8500:8500 -e acceptEULA=YES -e password:admin -e JAVA_OPTS="-Ddeep.service.url=172.17.0.1:43315 -Ddeep.logging.level=FINE -Ddeep.service.secure=false -Ddeep.transform.path=/opt/dispath" -v ${PWD}/dispath:/opt/dispath -v ${PWD}/agent/target/agent-1.0-SNAPSHOT.jar:/opt/deep/deep.jar ghcr.io/intergral/deep:coldfusion
```

Changing the -v paths to point to the locations on your machine. You also need to use the debug listen config ("Listen for Docker debug
connections") that should be available with this project in idea.
16 changes: 16 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright (C) 2023 Intergral GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
22 changes: 22 additions & 0 deletions LICENSING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Licensing

License names used in this document are as per [SPDX License List](https://spdx.org/licenses/).

The default license for this project is [AGPL-3.0-only](LICENSE).

## Apache-2.0

The following folders and their subfolders are licensed under Apache-2.0:

```

```

The following file or directories and their subdirectories are licensed under their original upstream licenses:

```
agent/src/main/java/com/intergral/deep/agent/resource
agent/src/main/java/com/intergral/deep/agent/IDUtils.java
agent-api/src/main/java/com/intergral/deep/agent/api/resource
agent-api/src/main/java/com/intergral/deep/agent/api/spi
```
29 changes: 29 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@


.PHONY: pmd
pmd:
mvn -U -B verify -Ppmd -DskipTests $(MVN_ARGS)

,PHONY: lint
lint:
mvn -U -B validate -Plint,examples,cf-it-tests $(MVN_ARGS)

.PHONY: test
test:
mvn -U -B clean verify $(MVN_ARGS)

.PHONY: docs
docs:
mvn -s .ci-settings.xml clean package javadoc:jar -DskipTests -P release-ossrh -B -U -pl agent,deep --also-make $(MVN_ARGS)

.PHONY: package-agent
package:
mvn package -U -B -pl agent --also-make -DskipTests $(MVN_ARGS)

.PHONY: cf-tests
cf-tests:
mvn verify -U -B -P cf-it-tests -pl it-tests/cf-tests --also-make $(MVN_ARGS)
# This file just contains shortcuts for dev, as there are a lot of options for different builds

.PHONY: build
Expand All @@ -8,3 +33,7 @@ build:
.PHONY: install
install:
mvn clean install -U -B -pl agent,deep --also-make $(MVN_ARGS)

.PHONY: coverage
coverage:
mvn clean verify -U -B -P coverage -pl '!it-tests/java-tests,!it-tests'
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ Deep.start()

There are a couple of examples [available here](./examples/README.md).

## Developing

## CF Debugging
For help developing this see [DEVELOPMENT.md](./DEVELOPMENT.md)

To debug in CF I found the easiest way is to use the docker. We can do this with this command:
```bash
docker run --name cf_2018 --rm -p 8500:8500 -p 8088:8088 -p 5005:5005 -e STRIP_STD=true -e FR_ENABLED=false -e NV_ENABLED=false -e JAVA_OPTS="-javaagent:/opt/deep/deep.jar -Ddeep.service.url=172.17.0.1:43315 -Ddeep.logging.level=FINE -Ddeep.service.secure=false -Ddeep.transform.path=/opt/dispath -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005" -v ${PWD}/dispath:/opt/dispath -v ${PWD}/agent/target/agent-1.0-SNAPSHOT.jar:/opt/deep/deep.jar registry.gitlab.com/intergral/docker/servers/coldfusion:2018
```
## Licensing

Changing the -v paths to point to the locations on your machine. You also need to use the debug listen config ("Listen for Docker debug connections") that should be available with this project in idea.
For licensing info please see [LICENSING.md](./LICENSING.md)
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package com.intergral.deep.agent.api;

public class DeepVersion {
public interface DeepVersion {

public static final String VERSION = "${project.version}";
String VERSION = "${project.version}";
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,26 @@

package com.intergral.deep.agent.api;

/**
* A general exception used by deep to throw {@link RuntimeException}.
*/
public class DeepRuntimeException extends RuntimeException {

/**
* Create a new exception with a message.
*
* @param message the error message
*/
public DeepRuntimeException(final String message) {
super(message);
}

/**
* Create a new exception with a message and cause.
*
* @param message the error message
* @param cause the cause of the error
*/
public DeepRuntimeException(final String message, final Throwable cause) {
super(message, cause);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public interface IRegistration<T> {
void unregister();

/**
* Get the registered item
* Get the registered item.
*
* @return the item that this registration is for.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,33 @@

import com.intergral.deep.agent.api.DeepRuntimeException;
import com.intergral.deep.agent.api.plugin.IPlugin;
import com.intergral.deep.agent.api.reflection.IReflection;
import com.intergral.deep.agent.api.reflection.ReflectionUtils;
import com.intergral.deep.agent.api.settings.ISettings;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Collections;
import java.util.Map;

public class AuthProvider {
/**
* A utility class to load the configured {@link IAuthProvider}.
*/
public final class AuthProvider {

private AuthProvider() {
}

private static final NoopProvider NOOP_PROVIDER = new NoopProvider();

public static IAuthProvider provider(final ISettings settings) {
/**
* Load the configured {@link IAuthProvider}.
* <p>
* This will always return a {@link IAuthProvider}.
*
* @param settings the current settings
* @param reflection the reflection service that is available
* @return the loaded {@link IAuthProvider}
*/
public static IAuthProvider provider(final ISettings settings, final IReflection reflection) {
final String serviceAuthProvider = settings.getSettingAs("service.auth.provider", String.class);
if (serviceAuthProvider == null || serviceAuthProvider.trim().isEmpty()) {
return NOOP_PROVIDER;
Expand All @@ -48,19 +64,14 @@ public static IAuthProvider provider(final ISettings settings) {

try {
final Class<?> aClass = Class.forName(serviceAuthProvider);
final Constructor<?> constructor = aClass.getConstructor(ISettings.class);
final Object newInstance = constructor.newInstance(settings);
return (IAuthProvider) newInstance;
} catch (ClassNotFoundException
| NoSuchMethodException
| InvocationTargetException
| InstantiationException
| IllegalAccessException e) {
final Constructor<?> constructor = ReflectionUtils.findConstructor(aClass, reflection);
return ReflectionUtils.callConstructor(constructor, settings, reflection);
} catch (ClassNotFoundException e) {
throw new RuntimeException(String.format("Cannot load auth provider %s", serviceAuthProvider), e);
}
}

private static class NoopProvider implements IAuthProvider {
static class NoopProvider implements IAuthProvider {

@Override
public Map<String, String> provide() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@
import java.util.Collections;
import java.util.Map;

/**
* This is an {@link IAuthProvider} that will attach basic authorization to the outbound requests.
* <p>
* This provider can be set using {@code service.auth.provider=com.intergral.deep.agent.api.auth.BasicAuthProvider}. The username and
* password that is configured onto requests can be set with the setting:
* <ul>
* <li>{@code service.username=yourusername}</li>
* <li>{@code service.password=yourpassword}</li>
* </ul>
* <p>
* These values are then base64 encoded and attached to the outbound requests as the {@code authorization} header.
*/
public class BasicAuthProvider implements IAuthProvider {

private final ISettings settings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@

import java.util.Map;

/**
* Allows for custom auth providers to be configured. These can be provided as an instantiatable class using the class name via the setting
* {@code service.auth.provider}. Alternatively a plugin can be configured as an auth provider.
*/
public interface IAuthProvider {

/**
* Provide the headers that should be attached to the GRPC calls
* Provide the headers that should be attached to the GRPC calls.
*
* @return a Map of the header values
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,22 @@
import com.intergral.deep.agent.api.IDeep;
import com.intergral.deep.agent.api.reflection.IReflection;

/**
* This type is used to pass an object from the agent to the API. It should not be directly used by clients.
*/
public interface IDeepHook {

/**
* Get the deep service from the agent.
*
* @return the deep agent.
*/
IDeep deepService();

/**
* Get the configured reflection api.
*
* @return the reflection api.
*/
IReflection reflectionService();
}
Loading