attackmap-analyzer-go 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- attackmap_analyzer_go-0.2.0/LICENSE +21 -0
- attackmap_analyzer_go-0.2.0/PKG-INFO +103 -0
- attackmap_analyzer_go-0.2.0/README.md +64 -0
- attackmap_analyzer_go-0.2.0/pyproject.toml +74 -0
- attackmap_analyzer_go-0.2.0/setup.cfg +4 -0
- attackmap_analyzer_go-0.2.0/src/attackmap_analyzer_go/__init__.py +3 -0
- attackmap_analyzer_go-0.2.0/src/attackmap_analyzer_go/analyzer.py +727 -0
- attackmap_analyzer_go-0.2.0/src/attackmap_analyzer_go/route_auth.py +911 -0
- attackmap_analyzer_go-0.2.0/src/attackmap_analyzer_go.egg-info/PKG-INFO +103 -0
- attackmap_analyzer_go-0.2.0/src/attackmap_analyzer_go.egg-info/SOURCES.txt +13 -0
- attackmap_analyzer_go-0.2.0/src/attackmap_analyzer_go.egg-info/dependency_links.txt +1 -0
- attackmap_analyzer_go-0.2.0/src/attackmap_analyzer_go.egg-info/entry_points.txt +2 -0
- attackmap_analyzer_go-0.2.0/src/attackmap_analyzer_go.egg-info/requires.txt +9 -0
- attackmap_analyzer_go-0.2.0/src/attackmap_analyzer_go.egg-info/top_level.txt +1 -0
- attackmap_analyzer_go-0.2.0/tests/test_go_analyzer.py +1586 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Matthew Davis and AttackMap Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: attackmap-analyzer-go
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Go ecosystem analyzer plugin for AttackMap (net/http, chi, gin, echo, fiber, gorilla/mux; database/sql, gorm, sqlx, pgx; golang-jwt; resty).
|
|
5
|
+
Author: AttackMap Contributors
|
|
6
|
+
Author-email: Matthew Davis <mlaify@mlaify.io>
|
|
7
|
+
Maintainer-email: Matthew Davis <mlaify@mlaify.io>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
Project-URL: Homepage, https://github.com/mlaify/attackmap-analyzer-go
|
|
10
|
+
Project-URL: Repository, https://github.com/mlaify/attackmap-analyzer-go
|
|
11
|
+
Project-URL: Issues, https://github.com/mlaify/attackmap-analyzer-go/issues
|
|
12
|
+
Project-URL: Changelog, https://github.com/mlaify/attackmap-analyzer-go/blob/main/CHANGELOG.md
|
|
13
|
+
Project-URL: AttackMap core, https://github.com/mlaify/AttackMap
|
|
14
|
+
Keywords: security,static-analysis,appsec,defensive-security,attackmap,attackmap-plugin
|
|
15
|
+
Classifier: Development Status :: 4 - Beta
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: Intended Audience :: Information Technology
|
|
18
|
+
Classifier: Intended Audience :: System Administrators
|
|
19
|
+
Classifier: Operating System :: OS Independent
|
|
20
|
+
Classifier: Programming Language :: Python :: 3
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
25
|
+
Classifier: Topic :: Security
|
|
26
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
27
|
+
Classifier: Typing :: Typed
|
|
28
|
+
Requires-Python: >=3.11
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
License-File: LICENSE
|
|
31
|
+
Requires-Dist: pydantic>=2.7.0
|
|
32
|
+
Provides-Extra: core
|
|
33
|
+
Requires-Dist: attackmap>=0.6.0; extra == "core"
|
|
34
|
+
Provides-Extra: dev
|
|
35
|
+
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
36
|
+
Requires-Dist: build>=1.2.0; extra == "dev"
|
|
37
|
+
Requires-Dist: attackmap>=0.6.0; extra == "dev"
|
|
38
|
+
Dynamic: license-file
|
|
39
|
+
|
|
40
|
+
# attackmap-analyzer-go
|
|
41
|
+
|
|
42
|
+
> [!IMPORTANT]
|
|
43
|
+
> **Active development, slow pace.** AttackMap is under active development, but
|
|
44
|
+
> progress may be slow until more contributors or co-maintainers join. Help is
|
|
45
|
+
> very welcome with the core engine, an analyzer, the macOS app, or the docs —
|
|
46
|
+
> see [CONTRIBUTING.md](CONTRIBUTING.md) or open an issue on
|
|
47
|
+
> [mlaify/AttackMap](https://github.com/mlaify/AttackMap/issues) to say hello.
|
|
48
|
+
> Security reports are still welcome at [security@mlaify.io](mailto:security@mlaify.io).
|
|
49
|
+
|
|
50
|
+
Go ecosystem analyzer for [AttackMap](https://github.com/mlaify/AttackMap).
|
|
51
|
+
|
|
52
|
+
This analyzer extracts structured signals from Go modules and workspaces:
|
|
53
|
+
|
|
54
|
+
- **Web frameworks** — net/http (stdlib), chi, gin, echo, fiber, gorilla/mux (route + entrypoint extraction)
|
|
55
|
+
- **Databases** — `database/sql` (Postgres / MySQL / SQLite drivers), gorm (with driver-aware kind inference), sqlx, pgx, mongo-go-driver, go-redis, bbolt, AWS SDK (S3, DynamoDB)
|
|
56
|
+
- **Auth packages** — golang-jwt, golang.org/x/oauth2, gorilla/sessions, casbin, x/crypto/bcrypt / scrypt / argon2, go-chi/jwtauth, echo-jwt
|
|
57
|
+
- **HTTP clients (external calls)** — net/http (`http.Get` / `http.Post` / `http.NewRequest`), go-resty, grequests
|
|
58
|
+
- **Secrets** — `os.Getenv`, `os.LookupEnv`, `godotenv`, `viper.GetString`
|
|
59
|
+
- **Service hints** — module name extracted from `go.mod`
|
|
60
|
+
|
|
61
|
+
All emissions populate AttackMap's Signal v2 fields (line numbers, evidence snippets, confidence scores) so downstream insights can cite `path/to/file.go:NN`.
|
|
62
|
+
|
|
63
|
+
## Install
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
uv tool install attackmap --with attackmap-analyzer-go \
|
|
67
|
+
--index mlaify=https://pkg.mlaify.io/pypi/simple/ --index-strategy first-index
|
|
68
|
+
# or from source:
|
|
69
|
+
pip install git+https://github.com/mlaify/attackmap-analyzer-go.git
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The analyzer is auto-discovered by AttackMap via the `attackmap.analyzers` entry-point group.
|
|
73
|
+
|
|
74
|
+
## Usage with AttackMap
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
# Auto-discovered when installed:
|
|
78
|
+
attackmap analyze /path/to/go/repo
|
|
79
|
+
|
|
80
|
+
# Or invoke explicitly:
|
|
81
|
+
attackmap analyze /path/to/go/repo --module go
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Detection
|
|
85
|
+
|
|
86
|
+
`detect()` returns true when any of the following are present, ignoring `vendor/`, `.git/`, `node_modules/`, `dist/`, and `build/`:
|
|
87
|
+
|
|
88
|
+
- A `go.mod` or `go.sum` at the repository root, or anywhere in the tree
|
|
89
|
+
- One or more `.go` files in the tree
|
|
90
|
+
|
|
91
|
+
## Coverage notes
|
|
92
|
+
|
|
93
|
+
- **Framework-aware route extraction**: chi/echo/fiber all use the same title-case verb pattern (`r.Get(...)`, `r.Post(...)`). To avoid mis-attributing generic `.Get(...)` calls (e.g., on a map type) as routes, the analyzer only fires those extractors when the file *also* contains a recognizable framework marker (`go-chi/chi` import, `chi.NewRouter(`, `labstack/echo`, `echo.New(`, etc.).
|
|
94
|
+
- **gorilla/mux + net/http**: when both are detected in the same file, only the gorilla extractor runs. The stdlib `HandleFunc` extractor would otherwise double-count the same routes.
|
|
95
|
+
- **Method extraction**: gin uses uppercase methods (`r.GET`); chi/echo/fiber use title-case (`r.Get`), and chi also `r.Method("GET", "/x", h)`; gorilla/mux reads `.Methods("GET", http.MethodPost)` anywhere in the route's chain (`r.HandleFunc("/x", h).Methods(...)`, `r.Path("/x").Methods(...).HandlerFunc(h)`). net/http `HandleFunc` / `Handle` read Go 1.22 patterns: `"GET /items/{id}"` is `GET /items/{id}`, and a host (`"POST example.com/x"`) is kept as a `route_host:example.com` service hint quoting the registration. A pattern without a method is `ANY`.
|
|
96
|
+
- **Handlers**: any handler argument works — a name, a closure, or a wrapped handler (`authMW(h)`), for `HandleFunc` and `Handle` alike. Path literals can be interpreted (`"/x"`) or raw (`` `/x` ``) strings. `http.Handle("/", r)`, which serves a router built in the file, isn't a route of its own.
|
|
97
|
+
- **Group and sub-router prefixes**: a route's path is joined with the prefixes of the groups it's registered in: gin/echo/fiber `g := r.Group("/api")` (nested), chi `r.Route("/admin", func(r chi.Router) {...})` and `r.Route("/admin", adminRoutes)`, chi/fiber `r.Mount("/admin", sub)` / `r.Mount("/admin", adminRouter())` / `r.Mount("/admin", h.Routes())` (the function or method must be in the same file), fiber `app.Route("/x", func(api fiber.Router) {...})`, gorilla `api := r.PathPrefix("/api").Subrouter()`, and parameterless group closures of group-stack routers (gitea's `m.Group("/repos", func() {...})`). A prefix that isn't a literal (`e.Group(cfg.RootPath)`) stops the join: the path is relative to it. A router mounted twice, or mounted and used any other way, keeps its own paths and its auth is `unknown`, since it may be reachable without the parent's middleware. "Any other way" means anything but its own method calls (`sub.Get(...)`, `sub.Use(...)`) and the mount: passed as an argument (`http.ListenAndServe(addr, sub)`, `http.Serve(ln, sub)`, `handlers.LoggingHandler(w, sub)`), assigned (`srv.Handler = sub`), or `sub.ServeHTTP`. The same applies to a builder function or method used again (`apiRouter()`, `h.Routes()`). Occurrences in strings and comments, and fields of other values (`cfg.sub`), don't count. A path and method registered twice in a file with different auth is `unknown`: which registration serves the request depends on the framework. Chi `r.With(mw...).Route("/x", func(r chi.Router) {...})` / `.Group(...)` closures carry the prefix and the inline middleware. A derivation deeper than 32 levels keeps the route's own path. Prefixes set up in another function or file (`users.Register(v1.Group("/users"))`, gitea's `r.Mount("/api/v1", apiv1.Routes())`) aren't joined.
|
|
98
|
+
- **Route auth (AttackMap#256)**: each chi/gin/echo/fiber route carries `auth` (`required` / `anonymous` / `unknown`), `guards` and `guard_evidence`. Routers are tracked by variable within a file: constructors, `g := r.Group("/x", mw...)`, chi `r.With(mw...)` and `r.Group(func(r chi.Router) {...})` / `r.Route(...)` closures. A router passed in as a parameter is tracked within its function. `X.Use(mw)` applies to routes registered on `X` (or routers derived from it) *after* the call, and fiber's `Use("/prefix", mw)` only under the prefix. Route-local middleware is gin/fiber `r.POST(path, mw..., h)`, echo `e.POST(path, h, mw...)` and chi `r.With(mw).Post(...)`. A middleware is a guard when its name says it authenticates (`AuthRequired`, `jwtauth.Authenticator`, `middleware.JWT`, `echojwt.WithConfig`, `jwtware.New`, `keyauth.New`, `BasicAuth`, …). `jwtauth.Verifier` and `Optional*` middleware don't count. A guard's `Skipper` / `Next` / `Filter` that only compares the path with literals (`c.Path() == "/signup"`, `strings.HasPrefix(c.Path(), "/hooks/")`) makes the named routes `anonymous`. Any other skipper, or a config passed by variable, leaves them `unknown`. Group middleware carries over with the prefix: a guard on a group, sub-router or mounting router applies to the routes registered in it. gorilla `r.Use(mw)` applies to every route of `r` and its subrouters whenever they were registered, as gorilla runs it. A handler wrapped in auth middleware (`mux.Handle("/x", requireAuth(h))`, chi `r.Post("/x", authMW(h))`) is guarded when the called name (the last dotted segment) is middleware-shaped (`authMW`, `requireAuth`, `auth.Middleware`), or is `Handler` / `Wrap` on a middleware-named receiver (`jwtMiddleware.Handler`); `auth.LoginHandler(db)`, `authMW.LoginHandler(db)` and `oauthMiddleware.Callback(cb)` are handlers, not guards. The trailing middleware of a parameterless group closure (gitea's `m.Group("/x", func() {...}, mw)`) isn't read: it belongs to a project's own wrapper whose semantics can't be told from the name.
|
|
99
|
+
- **gRPC**: framework presence and `grpc.NewServer` entrypoint are detected. Per-service / per-method route extraction would require parsing `.proto` files — not yet supported.
|
|
100
|
+
|
|
101
|
+
## License
|
|
102
|
+
|
|
103
|
+
MIT
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# attackmap-analyzer-go
|
|
2
|
+
|
|
3
|
+
> [!IMPORTANT]
|
|
4
|
+
> **Active development, slow pace.** AttackMap is under active development, but
|
|
5
|
+
> progress may be slow until more contributors or co-maintainers join. Help is
|
|
6
|
+
> very welcome with the core engine, an analyzer, the macOS app, or the docs —
|
|
7
|
+
> see [CONTRIBUTING.md](CONTRIBUTING.md) or open an issue on
|
|
8
|
+
> [mlaify/AttackMap](https://github.com/mlaify/AttackMap/issues) to say hello.
|
|
9
|
+
> Security reports are still welcome at [security@mlaify.io](mailto:security@mlaify.io).
|
|
10
|
+
|
|
11
|
+
Go ecosystem analyzer for [AttackMap](https://github.com/mlaify/AttackMap).
|
|
12
|
+
|
|
13
|
+
This analyzer extracts structured signals from Go modules and workspaces:
|
|
14
|
+
|
|
15
|
+
- **Web frameworks** — net/http (stdlib), chi, gin, echo, fiber, gorilla/mux (route + entrypoint extraction)
|
|
16
|
+
- **Databases** — `database/sql` (Postgres / MySQL / SQLite drivers), gorm (with driver-aware kind inference), sqlx, pgx, mongo-go-driver, go-redis, bbolt, AWS SDK (S3, DynamoDB)
|
|
17
|
+
- **Auth packages** — golang-jwt, golang.org/x/oauth2, gorilla/sessions, casbin, x/crypto/bcrypt / scrypt / argon2, go-chi/jwtauth, echo-jwt
|
|
18
|
+
- **HTTP clients (external calls)** — net/http (`http.Get` / `http.Post` / `http.NewRequest`), go-resty, grequests
|
|
19
|
+
- **Secrets** — `os.Getenv`, `os.LookupEnv`, `godotenv`, `viper.GetString`
|
|
20
|
+
- **Service hints** — module name extracted from `go.mod`
|
|
21
|
+
|
|
22
|
+
All emissions populate AttackMap's Signal v2 fields (line numbers, evidence snippets, confidence scores) so downstream insights can cite `path/to/file.go:NN`.
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
uv tool install attackmap --with attackmap-analyzer-go \
|
|
28
|
+
--index mlaify=https://pkg.mlaify.io/pypi/simple/ --index-strategy first-index
|
|
29
|
+
# or from source:
|
|
30
|
+
pip install git+https://github.com/mlaify/attackmap-analyzer-go.git
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The analyzer is auto-discovered by AttackMap via the `attackmap.analyzers` entry-point group.
|
|
34
|
+
|
|
35
|
+
## Usage with AttackMap
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# Auto-discovered when installed:
|
|
39
|
+
attackmap analyze /path/to/go/repo
|
|
40
|
+
|
|
41
|
+
# Or invoke explicitly:
|
|
42
|
+
attackmap analyze /path/to/go/repo --module go
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Detection
|
|
46
|
+
|
|
47
|
+
`detect()` returns true when any of the following are present, ignoring `vendor/`, `.git/`, `node_modules/`, `dist/`, and `build/`:
|
|
48
|
+
|
|
49
|
+
- A `go.mod` or `go.sum` at the repository root, or anywhere in the tree
|
|
50
|
+
- One or more `.go` files in the tree
|
|
51
|
+
|
|
52
|
+
## Coverage notes
|
|
53
|
+
|
|
54
|
+
- **Framework-aware route extraction**: chi/echo/fiber all use the same title-case verb pattern (`r.Get(...)`, `r.Post(...)`). To avoid mis-attributing generic `.Get(...)` calls (e.g., on a map type) as routes, the analyzer only fires those extractors when the file *also* contains a recognizable framework marker (`go-chi/chi` import, `chi.NewRouter(`, `labstack/echo`, `echo.New(`, etc.).
|
|
55
|
+
- **gorilla/mux + net/http**: when both are detected in the same file, only the gorilla extractor runs. The stdlib `HandleFunc` extractor would otherwise double-count the same routes.
|
|
56
|
+
- **Method extraction**: gin uses uppercase methods (`r.GET`); chi/echo/fiber use title-case (`r.Get`), and chi also `r.Method("GET", "/x", h)`; gorilla/mux reads `.Methods("GET", http.MethodPost)` anywhere in the route's chain (`r.HandleFunc("/x", h).Methods(...)`, `r.Path("/x").Methods(...).HandlerFunc(h)`). net/http `HandleFunc` / `Handle` read Go 1.22 patterns: `"GET /items/{id}"` is `GET /items/{id}`, and a host (`"POST example.com/x"`) is kept as a `route_host:example.com` service hint quoting the registration. A pattern without a method is `ANY`.
|
|
57
|
+
- **Handlers**: any handler argument works — a name, a closure, or a wrapped handler (`authMW(h)`), for `HandleFunc` and `Handle` alike. Path literals can be interpreted (`"/x"`) or raw (`` `/x` ``) strings. `http.Handle("/", r)`, which serves a router built in the file, isn't a route of its own.
|
|
58
|
+
- **Group and sub-router prefixes**: a route's path is joined with the prefixes of the groups it's registered in: gin/echo/fiber `g := r.Group("/api")` (nested), chi `r.Route("/admin", func(r chi.Router) {...})` and `r.Route("/admin", adminRoutes)`, chi/fiber `r.Mount("/admin", sub)` / `r.Mount("/admin", adminRouter())` / `r.Mount("/admin", h.Routes())` (the function or method must be in the same file), fiber `app.Route("/x", func(api fiber.Router) {...})`, gorilla `api := r.PathPrefix("/api").Subrouter()`, and parameterless group closures of group-stack routers (gitea's `m.Group("/repos", func() {...})`). A prefix that isn't a literal (`e.Group(cfg.RootPath)`) stops the join: the path is relative to it. A router mounted twice, or mounted and used any other way, keeps its own paths and its auth is `unknown`, since it may be reachable without the parent's middleware. "Any other way" means anything but its own method calls (`sub.Get(...)`, `sub.Use(...)`) and the mount: passed as an argument (`http.ListenAndServe(addr, sub)`, `http.Serve(ln, sub)`, `handlers.LoggingHandler(w, sub)`), assigned (`srv.Handler = sub`), or `sub.ServeHTTP`. The same applies to a builder function or method used again (`apiRouter()`, `h.Routes()`). Occurrences in strings and comments, and fields of other values (`cfg.sub`), don't count. A path and method registered twice in a file with different auth is `unknown`: which registration serves the request depends on the framework. Chi `r.With(mw...).Route("/x", func(r chi.Router) {...})` / `.Group(...)` closures carry the prefix and the inline middleware. A derivation deeper than 32 levels keeps the route's own path. Prefixes set up in another function or file (`users.Register(v1.Group("/users"))`, gitea's `r.Mount("/api/v1", apiv1.Routes())`) aren't joined.
|
|
59
|
+
- **Route auth (AttackMap#256)**: each chi/gin/echo/fiber route carries `auth` (`required` / `anonymous` / `unknown`), `guards` and `guard_evidence`. Routers are tracked by variable within a file: constructors, `g := r.Group("/x", mw...)`, chi `r.With(mw...)` and `r.Group(func(r chi.Router) {...})` / `r.Route(...)` closures. A router passed in as a parameter is tracked within its function. `X.Use(mw)` applies to routes registered on `X` (or routers derived from it) *after* the call, and fiber's `Use("/prefix", mw)` only under the prefix. Route-local middleware is gin/fiber `r.POST(path, mw..., h)`, echo `e.POST(path, h, mw...)` and chi `r.With(mw).Post(...)`. A middleware is a guard when its name says it authenticates (`AuthRequired`, `jwtauth.Authenticator`, `middleware.JWT`, `echojwt.WithConfig`, `jwtware.New`, `keyauth.New`, `BasicAuth`, …). `jwtauth.Verifier` and `Optional*` middleware don't count. A guard's `Skipper` / `Next` / `Filter` that only compares the path with literals (`c.Path() == "/signup"`, `strings.HasPrefix(c.Path(), "/hooks/")`) makes the named routes `anonymous`. Any other skipper, or a config passed by variable, leaves them `unknown`. Group middleware carries over with the prefix: a guard on a group, sub-router or mounting router applies to the routes registered in it. gorilla `r.Use(mw)` applies to every route of `r` and its subrouters whenever they were registered, as gorilla runs it. A handler wrapped in auth middleware (`mux.Handle("/x", requireAuth(h))`, chi `r.Post("/x", authMW(h))`) is guarded when the called name (the last dotted segment) is middleware-shaped (`authMW`, `requireAuth`, `auth.Middleware`), or is `Handler` / `Wrap` on a middleware-named receiver (`jwtMiddleware.Handler`); `auth.LoginHandler(db)`, `authMW.LoginHandler(db)` and `oauthMiddleware.Callback(cb)` are handlers, not guards. The trailing middleware of a parameterless group closure (gitea's `m.Group("/x", func() {...}, mw)`) isn't read: it belongs to a project's own wrapper whose semantics can't be told from the name.
|
|
60
|
+
- **gRPC**: framework presence and `grpc.NewServer` entrypoint are detected. Per-service / per-method route extraction would require parsing `.proto` files — not yet supported.
|
|
61
|
+
|
|
62
|
+
## License
|
|
63
|
+
|
|
64
|
+
MIT
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "attackmap-analyzer-go"
|
|
7
|
+
version = "0.2.0"
|
|
8
|
+
description = "Go ecosystem analyzer plugin for AttackMap (net/http, chi, gin, echo, fiber, gorilla/mux; database/sql, gorm, sqlx, pgx; golang-jwt; resty)."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [
|
|
14
|
+
{name = "Matthew Davis", email = "mlaify@mlaify.io"},
|
|
15
|
+
{name = "AttackMap Contributors"},
|
|
16
|
+
]
|
|
17
|
+
maintainers = [
|
|
18
|
+
{name = "Matthew Davis", email = "mlaify@mlaify.io"},
|
|
19
|
+
]
|
|
20
|
+
keywords = [
|
|
21
|
+
"security",
|
|
22
|
+
"static-analysis",
|
|
23
|
+
"appsec",
|
|
24
|
+
"defensive-security",
|
|
25
|
+
"attackmap",
|
|
26
|
+
"attackmap-plugin",
|
|
27
|
+
]
|
|
28
|
+
classifiers = [
|
|
29
|
+
"Development Status :: 4 - Beta",
|
|
30
|
+
"Intended Audience :: Developers",
|
|
31
|
+
"Intended Audience :: Information Technology",
|
|
32
|
+
"Intended Audience :: System Administrators",
|
|
33
|
+
"Operating System :: OS Independent",
|
|
34
|
+
"Programming Language :: Python :: 3",
|
|
35
|
+
"Programming Language :: Python :: 3.11",
|
|
36
|
+
"Programming Language :: Python :: 3.12",
|
|
37
|
+
"Programming Language :: Python :: 3.13",
|
|
38
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
39
|
+
"Topic :: Security",
|
|
40
|
+
"Topic :: Software Development :: Quality Assurance",
|
|
41
|
+
"Typing :: Typed",
|
|
42
|
+
]
|
|
43
|
+
dependencies = [
|
|
44
|
+
"pydantic>=2.7.0",
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
[project.optional-dependencies]
|
|
48
|
+
core = [
|
|
49
|
+
"attackmap>=0.6.0",
|
|
50
|
+
]
|
|
51
|
+
dev = [
|
|
52
|
+
"pytest>=8.0.0",
|
|
53
|
+
"build>=1.2.0",
|
|
54
|
+
"attackmap>=0.6.0",
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
[project.urls]
|
|
58
|
+
Homepage = "https://github.com/mlaify/attackmap-analyzer-go"
|
|
59
|
+
Repository = "https://github.com/mlaify/attackmap-analyzer-go"
|
|
60
|
+
Issues = "https://github.com/mlaify/attackmap-analyzer-go/issues"
|
|
61
|
+
Changelog = "https://github.com/mlaify/attackmap-analyzer-go/blob/main/CHANGELOG.md"
|
|
62
|
+
"AttackMap core" = "https://github.com/mlaify/AttackMap"
|
|
63
|
+
|
|
64
|
+
[project.entry-points."attackmap.analyzers"]
|
|
65
|
+
go = "attackmap_analyzer_go:GoAnalyzer"
|
|
66
|
+
|
|
67
|
+
[tool.setuptools]
|
|
68
|
+
package-dir = {"" = "src"}
|
|
69
|
+
|
|
70
|
+
[tool.setuptools.packages.find]
|
|
71
|
+
where = ["src"]
|
|
72
|
+
|
|
73
|
+
[tool.pytest.ini_options]
|
|
74
|
+
testpaths = ["tests"]
|