Hook cheat sheet: JVM: Java, Kotlin, Scala, Clojure
How to add a vulnboxd runtime hook to a JVM: Java, Kotlin, Scala, Clojure service by hand. Find your setup in the table, then follow its block.
- Without source access: only the compose file changes; redeploy. With source access: you change the code or Dockerfile and rebuild.
- Hub automation says how much the hub's proposals do for you. Fully: approve the proposal in the hub; the block is the fallback when it failed. With conditions: the same, when the conditions listed hold. Partly: the hub pushes the compose part, the rest is yours. Not at all: everything is by hand.
/usr/local/lib/vulnboxd/traceis the hook directory vulnboxd installs on the vulnbox. Compose snippets mount it read-only at/opt/vbxtracein the container.- How to check that the hook works and undo it is at the end of the page.
- Runtime hooks explains what a hook does.
JVM (Java, Kotlin, Scala, Clojure)
| Setup | Use this when | Change | Hub automation |
|---|---|---|---|
| JVM agent (JAVA_TOOL_OPTIONS) | Depends on spring-boot, org.apache.tomcat, org.eclipse.jetty, io.undertow, io.javalin or 12 more (in pom.xml, Gradle or sbt files), and only if no project/plugins.sbt file matches the pattern below and no build.sbt file matches the pattern below | compose | fully |
Without source access
Only the compose file changes: the image and the code stay as they are.
JVM agent (JAVA_TOOL_OPTIONS)
- Use this when: JVM (Java, Kotlin, Scala, Clojure) service that depends on
spring-boot,org.apache.tomcat,org.eclipse.jetty,io.undertow,io.javalinor 12 more (inpom.xml, Gradle or sbt files), and only if noproject/plugins.sbtfile matches the pattern below and nobuild.sbtfile matches the pattern below. - Hub automation: fully. The hub proposes exactly this change and pushes it (one commit per container) once you approve it. Do it by hand only when the proposal failed, e.g. on an unusual compose file.
- Check and undo: hook mounted into the container
Mount the hook directory read-only and add -javaagent:/opt/vbxtrace/jvm/vbxtrace-agent.jar to JAVA_TOOL_OPTIONS. Image and source stay untouched; VBXTRACE=0 switches it off.
Compose: merge into the service (app is its name) and redeploy:
services:
app:
volumes:
- /usr/local/lib/vulnboxd/trace:/opt/vbxtrace:ro
environment:
JAVA_TOOL_OPTIONS: "-javaagent:/opt/vbxtrace/jvm/vbxtrace-agent.jar" # already set? append, separated by a spaceExact detection rules
Package J1 (JVM agent core), proposal J1:javaagent, defined in hooks/jvm/j1/proposals/javaagent.toml.
- Image matches (regex):
^(docker\.io/)?(library/)?(eclipse-temurin|openjdk|amazoncorretto|ibm-semeru-runtimes|ibmjava|sapmachine|maven|gradle|clojure|sbtscala/|azul/zulu|bellsoft/liberica),^(docker\.io/)?(library/)?tomcat:,^(docker\.io/)?(library/)?jetty:,gcr\.io/distroless/java,^quay\.io/quarkus/,^registry\.access\.redhat\.com/ubi\d/openjdk - Command matches (regex):
\bjava\b,\bcatalina\.sh\b,\bmvnw?\b.*\b(spring-boot:run|exec:java),\bgradlew?\b.*\brun\b,\blein\b,\bsbt\b - Dependency on:
spring-boot,org.apache.tomcat,org.eclipse.jetty,io.undertow,io.javalin,com.sparkjava,io.netty,io.vertx,io.quarkus,io.micronaut,io.ktor,org.jetbrains.kotlinx:kotlinx-coroutines-core,com.typesafe.akka,org.apache.pekko,io.helidon,io.dropwizard,ring - Files:
pom.xml,build.gradle,build.gradle.kts,settings.gradle,settings.gradle.kts,*.jar,project.clj,deps.edn,build.sbt,mvnw,gradlew - Excluded: a
project/plugins.sbtfile matchingsbt-scala-native - Excluded: a
build.sbtfile matchingenablePlugins\(ScalaNativePlugin\)
Check that it works, and undo
Each block links the variant it needs.
Hook mounted into the container
Check: After the redeploy, this lists the processes that loaded the hook (empty: it is not loaded):
docker compose exec app sh -c 'grep -l vbxtrace /proc/[0-9]*/maps'The hub's Trace tab then shows links whose method starts with hook:.
Undo: Set VBXTRACE: "0" in the service's environment and restart it, or revert the commit (the hub's proposal screen has a revert per container). Remove the mount of /opt/vbxtrace only together with what loads from it: a runtime told to preload a missing file may refuse to start.