attackmap-analyzer-java-spring
Java and Kotlin Spring Boot ecosystem analyzer for AttackMap.
This analyzer extracts structured signals from Maven and Gradle projects:
- Web frameworks — Spring MVC / Spring Boot (annotation routing with class-level
@RequestMappingprefix joining), Spring WebFlux / WebMvc.fn functional endpoints (RouterFunctions, theroute()builder, Kotlinrouter {}/coRouter {}), JAX-RS / Jersey / Quarkus (@Path+@GET/@POST), Ktor (Kotlin DSL), Javalin, Micronaut - Route auth — Spring Security
authorizeHttpRequests/authorizeRequests/authorizeExchangerules and method security (@PreAuthorize,@Secured,@RolesAllowed) resolved per route intoRoute.auth/guards/guard_evidence - Databases — Spring Data JPA (
@Entity,JpaRepository), Spring Data MongoDB (@Document,MongoRepository), Spring Data Redis (RedisTemplate), JDBC (DriverManager.getConnectionwith driver-aware kind inference), Hibernate, jOOQ, AWS SDK (S3, DynamoDB) - Auth packages — Spring Security (
@PreAuthorize,@Secured,SecurityFilterChain,@EnableWebSecurity), jjwt / nimbus-jose-jwt, BCrypt / Argon2 / SCrypt password encoders, OAuth2 (oauth2Login,OAuth2AuthenticationToken) - HTTP clients (external calls) — RestTemplate, WebClient, java.net.http.HttpClient, OkHttpClient,
@FeignClient, Apache HttpClient - Secrets —
System.getenv,@Value("${...}"),Environment.getProperty(...) - Service hints —
<artifactId>frompom.xml,rootProject.namefrom Gradle settings,spring.application.namefromapplication.properties/application.yml
All emissions populate AttackMap's Signal v2 fields (line numbers, evidence snippets, confidence scores) so downstream insights can cite path/to/file.java:NN.
Install
uv tool install attackmap --with attackmap-analyzer-java-spring \
--index mlaify=https://pkg.mlaify.io/pypi/simple/ --index-strategy first-index
# or from source:
pip install git+https://github.com/mlaify/attackmap-analyzer-java-spring.git
The analyzer is auto-discovered by AttackMap via the attackmap.analyzers entry-point group.
Usage with AttackMap
# Auto-discovered when installed:
attackmap analyze /path/to/spring/repo
# Or invoke explicitly:
attackmap analyze /path/to/spring/repo --module java-spring
Detection
detect() returns true when any of the following are present, ignoring target/, build/, .gradle/, .mvn/, .idea/, .git/, out/, bin/, and node_modules/:
pom.xml,build.gradle,build.gradle.kts,settings.gradle, orsettings.gradle.ktsat the root.java,.kt, or.ktsfiles anywhere in the tree
Coverage notes
- Class-level
@RequestMappingprefix joining: a class annotated with@RequestMapping("/api/users")causes its method-level@GetMapping("/{id}")to emit as/api/users/{id}. Multiple classes in one file are tracked correctly — the prefix in effect is whichever class declaration most recently preceded the method annotation. @PostMappingwith no value (e.g.@PostMapping public Object create()) is not currently extracted — the regex requires a string argument. Workaround: write@PostMapping("")or@PostMapping("/"). Roadmap.- JAX-RS class + method
@Pathjoining: each class's own@Pathis the prefix for the methods in its body, and a verb (@GET,@POST, etc.) pairs only with the@Pathamong the annotations on the same method, so a neighbouring method's path is never borrowed. - Functional endpoints:
GET("/x")-style predicates and builder calls are read only in files that useorg.springframework.web.reactive.function.server,org.springframework.web.servlet.function,RouterFunctionsorRequestPredicates.nest(path("/api"), ...),.andNest(...), builder.path("/api", b -> ...)/.nest(path(...), b -> ...)and Kotlin"/api".nest {}/path("/api").nest {}add their prefix. A path that isn't a string literal (a constant, a Kotlin$template), and every route inside a nest whose prefix can't be read, is skipped rather than reported under a wrong path.GET(handler)with no path androute(path("/x").and(method(...)), h)are not read. - Spring Security rules → route auth: the matchers of
authorizeHttpRequests/authorizeRequests/authorizeExchange(lambda, pre-lambda.and()chain and Kotlinauthorize(...)DSL;requestMatchers/antMatchers/mvcMatchers/pathMatcherswith an optionalHttpMethod,anyRequest()/anyExchange(),web.ignoring()) are applied to Spring, JAX-RS and functional routes in first-match order with Ant/PathPattern matching (/**,/*,?,{var},{*var}).permitAll()/anonymous()giveauth = "anonymous";authenticated(),hasRole(..),hasAuthority(..),denyAll()and readableaccess(..)give"required"with the rule as the guard. A matcher that can't be read (a constant,regexMatchers, a loop over configured URLs) before the deciding rule leaves the route"unknown"unless it agrees. Several chains must agree unless asecurityMatcheror the config's package picks one; a chain applies only to routes in its own Maven/Gradle module (or, for a module without its own chain, a route-less shared security module); configs undertest/directories are ignored. The filter chain runs first, so method security can turn apermitAll()route into"required"but never opens a route the chain protects.csrf().disable()is reported by AttackMap core's web-hardening pass, not by this plugin. - When a route is never
required(the dangerous direction, since core then skips it):- a multi-segment route wildcard (
/files/**,{*rest}) is only fully covered by a pattern**; - a pattern without a leading
/is unreadable (Ant never matches it), and/admin/doesn't cover/admin; - trailing slash: Spring MVC 5 / Boot 2 routes
POST /admin/to/admin, and an exact Ant pattern (antMatchers,requestMatchers, the Kotlin DSL,antMatcher(..)) doesn't match it. Arequiredroute must stayrequiredfor that form too, or it becomesunknown. This is skipped only when the module is on Spring Boot 3+ (build file) or importsjakarta.servlet, andsetUseTrailingSlashMatch(true)isn't set.mvcMatchers,mvc.pattern(..)and WebFluxpathMatcherscover the trailing slash. JAX-RS routes always get the check; - HEAD: a
GETroute must also berequiredforHEAD, because Spring MVC runs the GET handler for HEAD and aHttpMethod.GETrule doesn't cover it; - the guiding rule: when an input the decision depends on can't be read with confidence, the answer is
unknown; hasRole/hasAnyRole/hasAuthorityneed string-literal arguments. Same-repo string constants resolve (#11):static final String NAME = "...";and Kotlinconst val, referenced asClass.NAME(or fully qualified), also inside+concatenations such as"hasAuthority(\"" + AuthoritiesConstants.ADMIN + "\")". Every member declaration of every class, interface (fields implicitly static final), enum, record and Kotlin object or companion object is recorded. A key resolves only when all its declarations in the repo are String constants with the same plain-literal value. Any other declaration poisons it: non-final or non-String, no literal initializer, a text block or raw string, an enum constant, aval/var, or a same-named class elsewhere declaring it differently. Hitting a size cap makes every lookup fail. Unqualified names and constants declared only undertest/stay unresolved. All of these giveunknown. AnANONYMOUSauthority givesanonymous. SpEL is read only as plain terms (hasRole('A'),isAuthenticated(),permitAll) joined byand/or, andorgivesrequiredonly if every branch does.==,eq,!,not, ternaries,#param,@beanand grouping giveunknown. The same applies to@PreAuthorize(one string literal, not a concatenation),@Securedand@RolesAllowed;- a
securityMatchers(m -> ...)lambda that names a method is an unreadable scope. Each request form (plain, trailing slash, HEAD) re-selects its chain bysecurityMatcher; - the nearest build file that declares a Spring Boot version decides Boot 2 vs 3, so a module's own Boot 2 wins over the root's Boot 3. Without one, a main-source
import jakarta.servlet...line counts as Spring 6. Spring 6.2'sUrlHandlerFilterre-enables the trailing-slash check, likesetUseTrailingSlashMatch(true); spring.mvc.servlet.pathbelow/, in application properties or YAML (nested keys followed by indentation) or as an unreadable${..}value, makes the module's Spring and functional routesunknown: Ant matchers then see the servlet path in front of the route. The same applies in code:addPathPrefix(..)with a non-root or unreadable prefix (predicates aren't read, so it covers the whole module), or the DispatcherServlet registered on a sub-path (DispatcherServletRegistrationBean, or aServletRegistrationBeanof the dispatcher servlet; other servlets such as an H2 console don't count). A non-root Jersey@ApplicationPathorspring.jersey.application-pathdoes the same for JAX-RS routes.server.servlet.context-pathis harmless, because matchers and routes both exclude it;- method security counts only when switched on in the route's module or a shared route-less module.
@PreAuthorizeneeds@EnableMethodSecurity/@EnableReactiveMethodSecurity/@EnableGlobalMethodSecurity(prePostEnabled = true).@SecuredneedssecuredEnabled = true.@RolesAllowed/@DenyAll/@PermitAllneedjsr250Enabled = true, or, for JAX-RS, Jersey'sRolesAllowedDynamicFeature/ Quarkus security.@PostAuthorizeruns after the handler and is never a guard, and@Secured("ROLE_ANONYMOUS")/@PreAuthorize("isAnonymous() or ...")aren't guards either; - several handlers on one route key (
params=/headers=variants) count as the least restrictive of them.
- a multi-segment route wildcard (
- Cost: per-file parsing is linear and capped (rules, chains, calls, pattern size). Applying rules to routes costs routes × chains × rules × entries, so it shares a per-repo budget of 5,000,000 cost units. Each matcher entry costs 20, each path match the size of its segment table, and each glob comparison pattern × text characters. A pattern segment with more than 8 wildcards is unreadable. Routes left when it runs out keep their chain answer
unknown. Not covered: Spring < 5.3 suffix-pattern matching (/admin.json) and@Orderbetween chains. - Kotlin Ktor:
routing { get("/x") { ... } }extraction only fires when the file contains anio.ktorimport orktor.server.routingreference, to avoid mis-attributingget(...)calls on Maps and other types. - Javalin and Micronaut are similarly framework-gated.
- OkHttp / java.net.http.HttpClient: literal-URL builder patterns (
new Request.Builder().url("https://..."),HttpRequest.newBuilder(URI.create("https://..."))) are picked up. Calls where the URL is built by string concatenation are not.
License
MIT
Metadata
Release files for attackmap-analyzer-java-spring 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| attackmap_analyzer_java_spring-0.2.0.tar.gz | 69.3 kB | With provenance | Details for attackmap_analyzer_java_spring-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| attackmap_analyzer_java_spring-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for attackmap_analyzer_java_spring-0.2.0-py3-none-any.whl |
Total release size: 117.5 kB
Release files / attackmap_analyzer_java_spring-0.2.0.tar.gz
| Download URL | attackmap_analyzer_java_spring-0.2.0.tar.gz |
|---|---|
| Size | 69.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
88aabe710281e43e3de6a504f9fe80cbf57f4569e736f49e300b2be8fd7ee391
|
|
BLAKE2b-256 checksum How to use checksums |
3beeb42be45562d2bee8c20aff2c7f0709648898fce286654a81e7f41e7651cf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logRelease files / attackmap_analyzer_java_spring-0.2.0-py3-none-any.whl
| Download URL | attackmap_analyzer_java_spring-0.2.0-py3-none-any.whl |
|---|---|
| Size | 48.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c21ad58956724b48d43ad4e08137827c428ee78d268154978065bfb6f9c6f669
|
|
BLAKE2b-256 checksum How to use checksums |
8d0849703f68c23f2bb473f37f03f055be1b5e0014bfe548258799fe068f58e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logSecurity for attackmap-analyzer-java-spring 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for attackmap_analyzer_java_spring-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.