@dataparade/cli 0.0.9 → 0.0.10

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.
Files changed (164) hide show
  1. package/README.md +1 -1
  2. package/dist/package.json +1 -1
  3. package/dist/src/ai-enrichment/lambda-init-error.d.ts +5 -0
  4. package/dist/src/ai-enrichment/lambda-init-error.js +38 -0
  5. package/dist/src/ai-enrichment/providers/platform-proxy-provider.d.ts +5 -0
  6. package/dist/src/ai-enrichment/providers/platform-proxy-provider.js +27 -1
  7. package/dist/src/analyzers/cpp/cpp-detection-config.d.ts +73 -0
  8. package/dist/src/analyzers/cpp/cpp-detection-config.js +137 -0
  9. package/dist/src/analyzers/cpp/dependency-manifests.d.ts +8 -0
  10. package/dist/src/analyzers/cpp/dependency-manifests.js +130 -0
  11. package/dist/src/analyzers/cpp/detector.d.ts +3 -0
  12. package/dist/src/analyzers/cpp/detector.js +21 -0
  13. package/dist/src/analyzers/cpp/index.d.ts +2 -0
  14. package/dist/src/analyzers/cpp/index.js +11 -0
  15. package/dist/src/analyzers/cpp/manifest-parsers.d.ts +13 -0
  16. package/dist/src/analyzers/cpp/manifest-parsers.js +104 -0
  17. package/dist/src/analyzers/cpp/parser.d.ts +35 -0
  18. package/dist/src/analyzers/cpp/parser.js +206 -0
  19. package/dist/src/analyzers/cpp/patterns.d.ts +3 -0
  20. package/dist/src/analyzers/cpp/patterns.js +37 -0
  21. package/dist/src/analyzers/csharp/csharp-detection-config.d.ts +100 -0
  22. package/dist/src/analyzers/csharp/csharp-detection-config.js +160 -0
  23. package/dist/src/analyzers/csharp/dependency-manifests.d.ts +13 -0
  24. package/dist/src/analyzers/csharp/dependency-manifests.js +184 -0
  25. package/dist/src/analyzers/csharp/detector.d.ts +3 -0
  26. package/dist/src/analyzers/csharp/detector.js +21 -0
  27. package/dist/src/analyzers/csharp/index.d.ts +2 -0
  28. package/dist/src/analyzers/csharp/index.js +11 -0
  29. package/dist/src/analyzers/csharp/manifest-parsers.d.ts +34 -0
  30. package/dist/src/analyzers/csharp/manifest-parsers.js +130 -0
  31. package/dist/src/analyzers/csharp/parser.d.ts +48 -0
  32. package/dist/src/analyzers/csharp/parser.js +277 -0
  33. package/dist/src/analyzers/csharp/patterns.d.ts +3 -0
  34. package/dist/src/analyzers/csharp/patterns.js +57 -0
  35. package/dist/src/analyzers/go/dependency-manifests.d.ts +10 -0
  36. package/dist/src/analyzers/go/dependency-manifests.js +117 -0
  37. package/dist/src/analyzers/go/detector.d.ts +3 -0
  38. package/dist/src/analyzers/go/detector.js +21 -0
  39. package/dist/src/analyzers/go/go-detection-config.d.ts +97 -0
  40. package/dist/src/analyzers/go/go-detection-config.js +164 -0
  41. package/dist/src/analyzers/go/index.d.ts +2 -0
  42. package/dist/src/analyzers/go/index.js +11 -0
  43. package/dist/src/analyzers/go/manifest-parsers.d.ts +20 -0
  44. package/dist/src/analyzers/go/manifest-parsers.js +104 -0
  45. package/dist/src/analyzers/go/parser.d.ts +40 -0
  46. package/dist/src/analyzers/go/parser.js +186 -0
  47. package/dist/src/analyzers/go/patterns.d.ts +3 -0
  48. package/dist/src/analyzers/go/patterns.js +50 -0
  49. package/dist/src/analyzers/jvm/dependency-manifests.d.ts +16 -0
  50. package/dist/src/analyzers/jvm/dependency-manifests.js +205 -0
  51. package/dist/src/analyzers/jvm/detector.d.ts +3 -0
  52. package/dist/src/analyzers/jvm/detector.js +21 -0
  53. package/dist/src/analyzers/jvm/index.d.ts +9 -0
  54. package/dist/src/analyzers/jvm/index.js +18 -0
  55. package/dist/src/analyzers/jvm/jvm-detection-config.d.ts +136 -0
  56. package/dist/src/analyzers/jvm/jvm-detection-config.js +195 -0
  57. package/dist/src/analyzers/jvm/manifest-parsers.d.ts +61 -0
  58. package/dist/src/analyzers/jvm/manifest-parsers.js +246 -0
  59. package/dist/src/analyzers/jvm/parser.d.ts +54 -0
  60. package/dist/src/analyzers/jvm/parser.js +419 -0
  61. package/dist/src/analyzers/jvm/patterns.d.ts +3 -0
  62. package/dist/src/analyzers/jvm/patterns.js +64 -0
  63. package/dist/src/analyzers/python/detector.js +1 -1
  64. package/dist/src/analyzers/python/parser.d.ts +1 -0
  65. package/dist/src/analyzers/python/parser.js +7 -0
  66. package/dist/src/analyzers/python/patterns.d.ts +1 -0
  67. package/dist/src/analyzers/python/patterns.js +22 -77
  68. package/dist/src/analyzers/python/python-detection-config.d.ts +18 -0
  69. package/dist/src/analyzers/python/python-detection-config.js +20 -0
  70. package/dist/src/analyzers/registry.js +15 -0
  71. package/dist/src/analyzers/shared/c-family-calls.d.ts +26 -0
  72. package/dist/src/analyzers/shared/c-family-calls.js +118 -0
  73. package/dist/src/analyzers/shared/strip-comments.d.ts +32 -0
  74. package/dist/src/analyzers/shared/strip-comments.js +167 -0
  75. package/dist/src/analyzers/typescript/detector.js +1 -1
  76. package/dist/src/analyzers/typescript/typescript-detection-config.d.ts +37 -0
  77. package/dist/src/analyzers/typescript/typescript-detection-config.js +48 -0
  78. package/dist/src/analyzers/typescript/typescript-detection.d.ts +1 -0
  79. package/dist/src/analyzers/typescript/typescript-detection.js +27 -29
  80. package/dist/src/cli.js +1 -1
  81. package/dist/src/config/file.js +5 -0
  82. package/dist/src/config/resolve.js +5 -0
  83. package/dist/src/core/pipeline/graph-mapping.js +3 -0
  84. package/dist/src/core/pipeline/structural-scan.js +154 -31
  85. package/dist/src/core/schema/scan-config.schema.d.ts +5 -0
  86. package/dist/src/core/schema/scan-config.schema.js +5 -0
  87. package/dist/src/core/schema/scan-result.schema.d.ts +5 -0
  88. package/dist/src/core/schema/scan-result.schema.js +5 -0
  89. package/dist/src/core/sectioning/discover-service-sections.js +27 -1
  90. package/dist/src/core/types/file.d.ts +1 -1
  91. package/dist/src/ingest/file-system.js +27 -0
  92. package/dist/src/patterns/config.d.ts +8 -0
  93. package/dist/src/patterns/config.js +136 -0
  94. package/dist/src/patterns/detectors/cpp.d.ts +8 -0
  95. package/dist/src/patterns/detectors/cpp.js +243 -0
  96. package/dist/src/patterns/detectors/csharp.d.ts +9 -0
  97. package/dist/src/patterns/detectors/csharp.js +385 -0
  98. package/dist/src/patterns/detectors/go.d.ts +9 -0
  99. package/dist/src/patterns/detectors/go.js +298 -0
  100. package/dist/src/patterns/detectors/helpers.d.ts +3 -0
  101. package/dist/src/patterns/detectors/helpers.js +5 -0
  102. package/dist/src/patterns/detectors/jvm.d.ts +15 -0
  103. package/dist/src/patterns/detectors/jvm.js +537 -0
  104. package/dist/src/patterns/detectors/python.d.ts +1 -0
  105. package/dist/src/patterns/detectors/python.js +92 -5
  106. package/dist/src/patterns/detectors/typescript.d.ts +2 -0
  107. package/dist/src/patterns/detectors/typescript.js +156 -4
  108. package/dist/src/patterns/engine.d.ts +18 -0
  109. package/dist/src/patterns/engine.js +30 -0
  110. package/dist/src/patterns/scan-exclusions.js +20 -0
  111. package/dist/tests/unit/ai-enrichment/lambda-init-error.spec.d.ts +1 -0
  112. package/dist/tests/unit/ai-enrichment/lambda-init-error.spec.js +11 -0
  113. package/dist/tests/unit/ai-enrichment/platform-proxy-provider.spec.js +80 -0
  114. package/dist/tests/unit/analyzers/cpp/dependency-manifests.spec.d.ts +1 -0
  115. package/dist/tests/unit/analyzers/cpp/dependency-manifests.spec.js +66 -0
  116. package/dist/tests/unit/analyzers/cpp/parser.spec.d.ts +1 -0
  117. package/dist/tests/unit/analyzers/cpp/parser.spec.js +80 -0
  118. package/dist/tests/unit/analyzers/cpp/patterns.spec.d.ts +1 -0
  119. package/dist/tests/unit/analyzers/cpp/patterns.spec.js +141 -0
  120. package/dist/tests/unit/analyzers/csharp/dependency-manifests.spec.d.ts +1 -0
  121. package/dist/tests/unit/analyzers/csharp/dependency-manifests.spec.js +75 -0
  122. package/dist/tests/unit/analyzers/csharp/parser.spec.d.ts +1 -0
  123. package/dist/tests/unit/analyzers/csharp/parser.spec.js +118 -0
  124. package/dist/tests/unit/analyzers/csharp/patterns.spec.d.ts +1 -0
  125. package/dist/tests/unit/analyzers/csharp/patterns.spec.js +210 -0
  126. package/dist/tests/unit/analyzers/go/dependency-manifests.spec.d.ts +1 -0
  127. package/dist/tests/unit/analyzers/go/dependency-manifests.spec.js +96 -0
  128. package/dist/tests/unit/analyzers/go/parser.spec.d.ts +1 -0
  129. package/dist/tests/unit/analyzers/go/parser.spec.js +110 -0
  130. package/dist/tests/unit/analyzers/go/patterns.spec.d.ts +1 -0
  131. package/dist/tests/unit/analyzers/go/patterns.spec.js +239 -0
  132. package/dist/tests/unit/analyzers/jvm/dependency-manifests.spec.d.ts +1 -0
  133. package/dist/tests/unit/analyzers/jvm/dependency-manifests.spec.js +179 -0
  134. package/dist/tests/unit/analyzers/jvm/parser.spec.d.ts +1 -0
  135. package/dist/tests/unit/analyzers/jvm/parser.spec.js +195 -0
  136. package/dist/tests/unit/analyzers/jvm/patterns.spec.d.ts +1 -0
  137. package/dist/tests/unit/analyzers/jvm/patterns.spec.js +284 -0
  138. package/dist/tests/unit/analyzers/python/patterns.spec.js +169 -0
  139. package/dist/tests/unit/analyzers/typescript/detector.spec.js +188 -0
  140. package/dist/tests/unit/core/cpp-dotnet-scan.spec.d.ts +1 -0
  141. package/dist/tests/unit/core/cpp-dotnet-scan.spec.js +67 -0
  142. package/dist/tests/unit/core/cpp-dotnet-sections.spec.d.ts +1 -0
  143. package/dist/tests/unit/core/cpp-dotnet-sections.spec.js +46 -0
  144. package/dist/tests/unit/core/go-scan.spec.d.ts +1 -0
  145. package/dist/tests/unit/core/go-scan.spec.js +78 -0
  146. package/dist/tests/unit/core/graph-mapping.spec.js +75 -0
  147. package/dist/tests/unit/core/jvm-scan.spec.d.ts +1 -0
  148. package/dist/tests/unit/core/jvm-scan.spec.js +94 -0
  149. package/dist/tests/unit/ingest/cpp-dotnet-languages.spec.d.ts +1 -0
  150. package/dist/tests/unit/ingest/cpp-dotnet-languages.spec.js +56 -0
  151. package/dist/tests/unit/ingest/jvm-languages.spec.d.ts +1 -0
  152. package/dist/tests/unit/ingest/jvm-languages.spec.js +47 -0
  153. package/package.json +1 -1
  154. package/patterns/cpp.md +176 -0
  155. package/patterns/cpp.patterns.yaml +314 -0
  156. package/patterns/csharp.md +211 -0
  157. package/patterns/csharp.patterns.yaml +375 -0
  158. package/patterns/go.md +211 -0
  159. package/patterns/go.patterns.yaml +429 -0
  160. package/patterns/jvm.md +160 -0
  161. package/patterns/jvm.patterns.yaml +884 -0
  162. package/patterns/python.patterns.yaml +177 -0
  163. package/patterns/third-party.patterns.yaml +5 -0
  164. package/patterns/typescript.patterns.yaml +222 -0
package/patterns/go.md ADDED
@@ -0,0 +1,211 @@
1
+ # Go Patterns (CLI Scanner)
2
+
3
+ This document describes the Go patterns implemented by the CLI codebase
4
+ scanner.
5
+
6
+ The Go analyzer emits `RawFinding[]` using the **shared pattern IDs** from
7
+ `core/types/detection.ts`:
8
+
9
+ - `express_route`
10
+ - `database_connection`
11
+ - `external_api_call`
12
+ - `auth_middleware`
13
+ - `config_file`
14
+ - `env_variable`
15
+ - `lambda_handler`
16
+
17
+ These pattern IDs align with the TypeScript/JavaScript, Python, C++, and C#
18
+ analyzers so that the classifier and data-flow detector treat every language
19
+ consistently.
20
+
21
+ ## Structure
22
+
23
+ - **YAML configuration** at `cli/patterns/go.patterns.yaml` defines pattern
24
+ IDs, import paths, call names, route regexes, and confidences.
25
+ - **Config loader** (`cli/src/analyzers/go/go-detection-config.ts`) validates
26
+ the YAML and compiles its regexes.
27
+ - **Parser** (`cli/src/analyzers/go/parser.ts`) produces a source-file model:
28
+ package name, imports (with alias and blank-import flags), functions (with
29
+ receiver types), types, and call sites.
30
+ - **Detectors** (`cli/src/patterns/detectors/go.ts`) run inside the shared
31
+ `matchPatterns()` engine.
32
+
33
+ ### Import path matching
34
+
35
+ `importPaths` values match a Go import path **exactly or as a path prefix**:
36
+
37
+ - `github.com/jackc/pgx` matches `github.com/jackc/pgx/v5/pgxpool`
38
+ - `github.com/redis/go-redis` matches `github.com/redis/go-redis/v9`
39
+
40
+ That single rule is what makes Go's module major-version suffixes (`/v5`,
41
+ `/v76`) and sub-package imports work without enumerating every variant.
42
+
43
+ ### Blank imports are a first-class signal
44
+
45
+ Go registers database drivers through import side effects:
46
+
47
+ ```go
48
+ import _ "github.com/lib/pq"
49
+ ```
50
+
51
+ The parser records `isBlank` for these, and driver rules match on the import
52
+ path alone — a blank import is often the *only* evidence in the file that a
53
+ particular database is in use.
54
+
55
+ ### Comment handling
56
+
57
+ Sources are pre-processed by `stripCommentsPreservingLayout()` with
58
+ `backtickStrings` enabled, so Go raw strings (`` `SELECT ... -- x` ``) survive
59
+ intact while comments are blanked to spaces and line numbers are preserved.
60
+ Commented-out routes produce no findings.
61
+
62
+ ---
63
+
64
+ ## Route / Handler Detection (`express_route`)
65
+
66
+ Route detection is regex-driven per framework and gated on the framework's
67
+ import path.
68
+
69
+ | Framework | Detected form |
70
+ | --- | --- |
71
+ | `net/http` | `mux.HandleFunc("/path", h)`, and Go 1.22+ `HandleFunc("GET /path", h)` |
72
+ | gorilla/mux | `r.HandleFunc("/path", h).Methods("POST")` |
73
+ | chi | `r.Get("/path", h)`, `r.Post(...)` |
74
+ | gin | `r.GET("/path", h)`, `r.POST(...)` |
75
+ | echo | `e.GET("/path", h)` |
76
+ | Fiber | `app.Get("/path", h)` |
77
+ | gRPC | `RegisterGreeterServer(s, &server{})` → `RPC` |
78
+
79
+ ### Avoiding double-reporting
80
+
81
+ Nearly every Go HTTP file imports `net/http`, so a gorilla/mux route would
82
+ otherwise match both the gorilla rule and the generic `net/http` rule. The
83
+ `net/http` pattern carries a trailing guard that refuses lines ending in
84
+ `.Methods(...)`, yielding those to the more specific gorilla rule:
85
+
86
+ ```yaml
87
+ - regex: '\bHandle(?:Func)?\s*\(\s*"(?!(?:GET|POST|…)\s)([^"]+)"(?:(?!\.Methods\().)*$'
88
+ ```
89
+
90
+ Go 1.22 method-prefixed patterns are matched by a separate rule, and the
91
+ generic rule's negative lookahead keeps it from claiming them a second time.
92
+
93
+ ---
94
+
95
+ ## Database Connections (`database_connection`)
96
+
97
+ Detected from an import path (including blank imports) or a call site.
98
+
99
+ | Client | `databaseType` | Import path |
100
+ | --- | --- | --- |
101
+ | lib/pq | `postgres` | `github.com/lib/pq` |
102
+ | pgx | `postgres` | `github.com/jackc/pgx` |
103
+ | go-sql-driver/mysql | `mysql` | `github.com/go-sql-driver/mysql` |
104
+ | go-sqlite3 | `sqlite` | `github.com/mattn/go-sqlite3`, `modernc.org/sqlite` |
105
+ | sqlx | `sql` | `github.com/jmoiron/sqlx` |
106
+ | GORM (+ drivers) | per driver | `gorm.io/gorm`, `gorm.io/driver/*` |
107
+ | ent | `sql` | `entgo.io/ent` |
108
+ | mongo-driver | `mongodb` | `go.mongodb.org/mongo-driver` |
109
+ | go-redis / redigo | `redis` | `github.com/redis/go-redis`, `github.com/gomodule/redigo` |
110
+ | gocql | `cassandra` | `github.com/gocql/gocql` |
111
+ | DynamoDB | `dynamodb` | `github.com/aws/aws-sdk-go-v2/service/dynamodb` |
112
+
113
+ ### `sql.Open` driver resolution
114
+
115
+ `database/sql` is deliberately engine-agnostic — the concrete engine appears
116
+ only as the first argument:
117
+
118
+ ```go
119
+ db, err := sql.Open("postgres", os.Getenv("DATABASE_URL"))
120
+ ```
121
+
122
+ The `sql_open` rule reads that argument and maps it through a driver table
123
+ (`postgres`/`pgx` → postgres, `mysql` → mysql, `sqlite3` → sqlite,
124
+ `sqlserver` → mssql, …), so the graph shows a Postgres node rather than a
125
+ generic SQL one. Unknown drivers fall back to `databaseType: "sql"` and the
126
+ driver string is preserved in `properties.driver`.
127
+
128
+ ---
129
+
130
+ ## External API Calls (`external_api_call`)
131
+
132
+ | Client | Signals |
133
+ | --- | --- |
134
+ | `net/http` | `http.Get`, `http.Post`, `http.NewRequest`, `client.Do` |
135
+ | resty | `resty.New()`, `.SetBaseURL(...)` |
136
+ | gRPC | `grpc.Dial(...)`, `grpc.NewClient(...)` |
137
+
138
+ Call matching is **exact on the fully qualified callee** (`http.Get`), not on
139
+ the trailing segment. This matters in Go: matching a bare `Get` would make
140
+ every chi router registration (`r.Get("/items", h)`) look like an outbound HTTP
141
+ call. There is a test asserting that exact case.
142
+
143
+ When the arguments contain a literal URL, the service name is resolved from the
144
+ third-party catalog — `https://api.stripe.com/...` → `stripe`.
145
+
146
+ ---
147
+
148
+ ## Auth (`auth_middleware`)
149
+
150
+ | Rule | Signals | `strategy` |
151
+ | --- | --- | --- |
152
+ | golang-jwt | `github.com/golang-jwt/jwt`, `jwt.Parse`, `jwt.NewWithClaims` | `jwt` |
153
+ | OAuth2 | `golang.org/x/oauth2` | `oauth2` |
154
+ | Casbin | `github.com/casbin/casbin` | `casbin` |
155
+ | Bearer header | literal `"Authorization"` / `Header.Get("Authorization")` | `bearer_token` |
156
+
157
+ ---
158
+
159
+ ## Serverless Handlers (`lambda_handler`)
160
+
161
+ | Runtime | Detected when |
162
+ | --- | --- |
163
+ | AWS Lambda | `github.com/aws/aws-lambda-go/lambda` + `lambda.Start(...)` |
164
+ | GCP Cloud Functions | `functions-framework-go` + `functions.HTTP(...)` |
165
+
166
+ ---
167
+
168
+ ## Config and Environment (`config_file`, `env_variable`)
169
+
170
+ - `env_variable` from `os.Getenv("KEY")` and `os.LookupEnv("KEY")`; the key is
171
+ captured into `properties.key`.
172
+ - `config_file` from configuration loaders: godotenv, Viper, envconfig.
173
+ - `config_file` for files named `config.go`, `configuration.go`, `settings.go`.
174
+
175
+ ---
176
+
177
+ ## Dependency Manifests
178
+
179
+ `cli/src/analyzers/go/dependency-manifests.ts` walks the repository for
180
+ `go.mod` and parses:
181
+
182
+ - the `module` declaration (the module's own path);
183
+ - both `require` forms — the parenthesised block and the single-line form;
184
+ - skipping `replace`, `exclude`, and `retract` blocks, which redirect or remove
185
+ dependencies rather than declare them.
186
+
187
+ Go is unusually well-suited to manifest-driven detection: **a `go.mod` require
188
+ token is the same string that appears in an `import` statement**, so module
189
+ paths feed the shared third-party catalog and the database rules directly, with
190
+ no name translation. `github.com/getsentry/sentry-go` resolves to `sentry`,
191
+ `github.com/lib/pq` to a Postgres client.
192
+
193
+ `go.work` workspace members are parsed as well (`parseGoWork`).
194
+
195
+ Manifest walking is bounded by the shared budgets in
196
+ `cli/src/analyzers/shared/manifest-budgets.ts`.
197
+
198
+ ---
199
+
200
+ ## Sections
201
+
202
+ `go.mod` is registered as a **service section marker**: in a multi-module
203
+ repository each module directory becomes its own section, which is exactly the
204
+ Go convention for service boundaries.
205
+
206
+ ---
207
+
208
+ ## File Types
209
+
210
+ The ingest layer maps `.go` to the `go` language. `vendor/` is already excluded
211
+ by the default scan exclusions.
@@ -0,0 +1,429 @@
1
+ # Go pattern config. All entries share: patternId, optional confidence (default 0.8).
2
+ #
3
+ # `importPaths` matches a Go import path exactly, or as a path prefix, so
4
+ # `github.com/jackc/pgx` also matches `github.com/jackc/pgx/v5/pgxpool`.
5
+ # That prefix rule is what makes module major-version suffixes (`/v5`) and
6
+ # sub-packages work without listing every variant.
7
+
8
+ db_clients:
9
+ - id: lib_pq
10
+ patternId: database_connection
11
+ databaseType: postgres
12
+ importPaths:
13
+ - github.com/lib/pq
14
+ confidence: 0.9
15
+
16
+ - id: pgx
17
+ patternId: database_connection
18
+ databaseType: postgres
19
+ importPaths:
20
+ - github.com/jackc/pgx
21
+ callNames:
22
+ - pgx.Connect
23
+ - pgx.ConnectConfig
24
+ - pgxpool.New
25
+ - pgxpool.Connect
26
+ confidence: 0.9
27
+
28
+ - id: go_sql_driver_mysql
29
+ patternId: database_connection
30
+ databaseType: mysql
31
+ importPaths:
32
+ - github.com/go-sql-driver/mysql
33
+ confidence: 0.9
34
+
35
+ - id: go_sqlite3
36
+ patternId: database_connection
37
+ databaseType: sqlite
38
+ importPaths:
39
+ - github.com/mattn/go-sqlite3
40
+ - modernc.org/sqlite
41
+ confidence: 0.9
42
+
43
+ - id: sqlx
44
+ patternId: database_connection
45
+ databaseType: sql
46
+ importPaths:
47
+ - github.com/jmoiron/sqlx
48
+ callNames:
49
+ - sqlx.Connect
50
+ - sqlx.Open
51
+ - sqlx.MustConnect
52
+ confidence: 0.85
53
+
54
+ - id: gorm_postgres
55
+ patternId: database_connection
56
+ databaseType: postgres
57
+ importPaths:
58
+ - gorm.io/driver/postgres
59
+ confidence: 0.9
60
+
61
+ - id: gorm_mysql
62
+ patternId: database_connection
63
+ databaseType: mysql
64
+ importPaths:
65
+ - gorm.io/driver/mysql
66
+ confidence: 0.9
67
+
68
+ - id: gorm_sqlite
69
+ patternId: database_connection
70
+ databaseType: sqlite
71
+ importPaths:
72
+ - gorm.io/driver/sqlite
73
+ confidence: 0.9
74
+
75
+ - id: gorm_sqlserver
76
+ patternId: database_connection
77
+ databaseType: mssql
78
+ importPaths:
79
+ - gorm.io/driver/sqlserver
80
+ confidence: 0.9
81
+
82
+ - id: gorm
83
+ patternId: database_connection
84
+ databaseType: sql
85
+ importPaths:
86
+ - gorm.io/gorm
87
+ - github.com/jinzhu/gorm
88
+ callNames:
89
+ - gorm.Open
90
+ confidence: 0.85
91
+
92
+ - id: ent
93
+ patternId: database_connection
94
+ databaseType: sql
95
+ importPaths:
96
+ - entgo.io/ent
97
+ confidence: 0.85
98
+
99
+ - id: mongo_driver
100
+ patternId: database_connection
101
+ databaseType: mongodb
102
+ importPaths:
103
+ - go.mongodb.org/mongo-driver
104
+ callNames:
105
+ - mongo.Connect
106
+ - mongo.NewClient
107
+ confidence: 0.9
108
+
109
+ - id: go_redis
110
+ patternId: database_connection
111
+ databaseType: redis
112
+ importPaths:
113
+ - github.com/redis/go-redis
114
+ - github.com/go-redis/redis
115
+ - github.com/gomodule/redigo
116
+ callNames:
117
+ - redis.NewClient
118
+ - redis.NewClusterClient
119
+ - redis.NewFailoverClient
120
+ confidence: 0.9
121
+
122
+ - id: gocql
123
+ patternId: database_connection
124
+ databaseType: cassandra
125
+ importPaths:
126
+ - github.com/gocql/gocql
127
+ callNames:
128
+ - gocql.NewCluster
129
+ confidence: 0.85
130
+
131
+ - id: dynamodb
132
+ patternId: database_connection
133
+ databaseType: dynamodb
134
+ importPaths:
135
+ - github.com/aws/aws-sdk-go-v2/service/dynamodb
136
+ - github.com/aws/aws-sdk-go/service/dynamodb
137
+ confidence: 0.85
138
+
139
+ - id: elastic_go
140
+ patternId: database_connection
141
+ databaseType: elasticsearch
142
+ importPaths:
143
+ - github.com/elastic/go-elasticsearch
144
+ - github.com/olivere/elastic
145
+ callNames:
146
+ - elasticsearch.NewDefaultClient
147
+ - elasticsearch.NewClient
148
+ - elastic.NewClient
149
+ - elastic.NewSimpleClient
150
+ confidence: 0.85
151
+
152
+ - id: clickhouse_go
153
+ patternId: database_connection
154
+ databaseType: clickhouse
155
+ importPaths:
156
+ - github.com/ClickHouse/clickhouse-go
157
+ callNames:
158
+ - clickhouse.Open
159
+ - clickhouse.OpenDB
160
+ confidence: 0.85
161
+
162
+ - id: gosnowflake
163
+ patternId: database_connection
164
+ databaseType: snowflake
165
+ importPaths:
166
+ - github.com/snowflakedb/gosnowflake
167
+ confidence: 0.85
168
+
169
+ - id: neo4j_go
170
+ patternId: database_connection
171
+ databaseType: neo4j
172
+ importPaths:
173
+ - github.com/neo4j/neo4j-go-driver
174
+ callNames:
175
+ - neo4j.NewDriverWithContext
176
+ - neo4j.NewDriver
177
+ confidence: 0.85
178
+
179
+ - id: mariadb_go
180
+ patternId: database_connection
181
+ databaseType: mariadb
182
+ importPaths:
183
+ - github.com/go-sql-driver/mysql
184
+ callNames:
185
+ - sql.Open
186
+ confidence: 0.75
187
+
188
+ # Go-specific: `database/sql` is driver-agnostic, and the concrete engine is
189
+ # named as the first argument of sql.Open. Reading it turns a generic "SQL"
190
+ # node into the actual engine.
191
+ sql_open:
192
+ patternId: database_connection
193
+ regex: 'sql\.Open(?:DB)?\s*\(\s*"([^"]+)"'
194
+ name: database_sql
195
+ confidence: 0.9
196
+ drivers:
197
+ postgres: postgres
198
+ postgresql: postgres
199
+ pgx: postgres
200
+ cloudsqlpostgres: postgres
201
+ mysql: mysql
202
+ sqlite3: sqlite
203
+ sqlite: sqlite
204
+ sqlserver: mssql
205
+ mssql: mssql
206
+ oracle: oracle
207
+ godror: oracle
208
+ clickhouse: clickhouse
209
+ snowflake: snowflake
210
+ mariadb: mariadb
211
+ neo4j: neo4j
212
+ defaultDatabaseType: sql
213
+
214
+ auth:
215
+ libraries:
216
+ - id: golang_jwt
217
+ patternId: auth_middleware
218
+ importPaths:
219
+ - github.com/golang-jwt/jwt
220
+ - github.com/dgrijalva/jwt-go
221
+ - github.com/lestrrat-go/jwx
222
+ callNames:
223
+ - jwt.Parse
224
+ - jwt.ParseWithClaims
225
+ - jwt.NewWithClaims
226
+ - jwt.New
227
+ strategy: jwt
228
+ confidence: 0.9
229
+
230
+ - id: oauth2
231
+ patternId: auth_middleware
232
+ importPaths:
233
+ - golang.org/x/oauth2
234
+ callNames:
235
+ - oauth2.Config
236
+ strategy: oauth2
237
+ confidence: 0.85
238
+
239
+ - id: casbin
240
+ patternId: auth_middleware
241
+ importPaths:
242
+ - github.com/casbin/casbin
243
+ strategy: casbin
244
+ confidence: 0.85
245
+
246
+ - id: bearer_token_header
247
+ patternId: auth_middleware
248
+ contentRegexes:
249
+ - '"Authorization"'
250
+ - 'Header\.Get\(\s*"Authorization"'
251
+ strategy: bearer_token
252
+ confidence: 0.7
253
+
254
+ routes:
255
+ frameworks:
256
+ - id: net_http
257
+ patternId: express_route
258
+ importPaths:
259
+ - net/http
260
+ confidence: 0.85
261
+ routeRegexes:
262
+ # Go 1.22+ method-prefixed patterns: HandleFunc("GET /users", h).
263
+ - regex: '\bHandle(?:Func)?\s*\(\s*"(GET|POST|PUT|DELETE|PATCH|HEAD|OPTIONS)\s+([^"]+)"'
264
+ methodGroup: 1
265
+ pathGroup: 2
266
+ # Plain patterns. The trailing guard yields lines ending in
267
+ # `.Methods("GET")` to the gorilla/mux rule so one route is not
268
+ # reported twice.
269
+ - regex: '\bHandle(?:Func)?\s*\(\s*"(?!(?:GET|POST|PUT|DELETE|PATCH|HEAD|OPTIONS)\s)([^"]+)"(?:(?!\.Methods\().)*$'
270
+ pathGroup: 1
271
+
272
+ - id: gorilla_mux
273
+ patternId: express_route
274
+ importPaths:
275
+ - github.com/gorilla/mux
276
+ confidence: 0.9
277
+ routeRegexes:
278
+ - regex: '\bHandleFunc\s*\(\s*"([^"]+)"[^)]*\)\s*\.Methods\(\s*"([A-Z]+)"'
279
+ pathGroup: 1
280
+ methodGroup: 2
281
+
282
+ - id: chi
283
+ patternId: express_route
284
+ importPaths:
285
+ - github.com/go-chi/chi
286
+ confidence: 0.9
287
+ routeRegexes:
288
+ - regex: '\b[A-Za-z_]\w*\.(Get|Post|Put|Delete|Patch|Head|Options)\s*\(\s*"([^"]+)"'
289
+ methodGroup: 1
290
+ pathGroup: 2
291
+
292
+ - id: gin
293
+ patternId: express_route
294
+ importPaths:
295
+ - github.com/gin-gonic/gin
296
+ confidence: 0.9
297
+ routeRegexes:
298
+ - regex: '\b[A-Za-z_]\w*\.(GET|POST|PUT|DELETE|PATCH|HEAD|OPTIONS|Any)\s*\(\s*"([^"]+)"'
299
+ methodGroup: 1
300
+ pathGroup: 2
301
+
302
+ - id: echo
303
+ patternId: express_route
304
+ importPaths:
305
+ - github.com/labstack/echo
306
+ confidence: 0.9
307
+ routeRegexes:
308
+ - regex: '\b[A-Za-z_]\w*\.(GET|POST|PUT|DELETE|PATCH|HEAD|OPTIONS)\s*\(\s*"([^"]+)"'
309
+ methodGroup: 1
310
+ pathGroup: 2
311
+
312
+ - id: fiber
313
+ patternId: express_route
314
+ importPaths:
315
+ - github.com/gofiber/fiber
316
+ confidence: 0.9
317
+ routeRegexes:
318
+ - regex: '\b[A-Za-z_]\w*\.(Get|Post|Put|Delete|Patch|Head|Options|All)\s*\(\s*"([^"]+)"'
319
+ methodGroup: 1
320
+ pathGroup: 2
321
+
322
+ - id: grpc
323
+ patternId: express_route
324
+ importPaths:
325
+ - google.golang.org/grpc
326
+ confidence: 0.8
327
+ routeRegexes:
328
+ - regex: '\bRegister([A-Za-z_]\w*)Server\s*\('
329
+ pathGroup: 1
330
+ defaultMethod: RPC
331
+
332
+ serverless:
333
+ handlers:
334
+ - id: aws_lambda_go
335
+ patternId: lambda_handler
336
+ importPaths:
337
+ - github.com/aws/aws-lambda-go/lambda
338
+ callNames:
339
+ - lambda.Start
340
+ - lambda.StartWithOptions
341
+ - lambda.StartHandler
342
+ confidence: 0.9
343
+
344
+ - id: gcp_functions_go
345
+ patternId: lambda_handler
346
+ importPaths:
347
+ - github.com/GoogleCloudPlatform/functions-framework-go
348
+ callNames:
349
+ - functions.HTTP
350
+ - functions.CloudEvent
351
+ confidence: 0.9
352
+
353
+ env_config:
354
+ envVariable:
355
+ patternId: env_variable
356
+ regex: '\bos\.(?:Getenv|LookupEnv)\s*\(\s*"([^"]+)"'
357
+ confidence: 0.85
358
+
359
+ configLoaders:
360
+ patternId: config_file
361
+ confidence: 0.85
362
+ loaders:
363
+ - id: godotenv
364
+ importPaths:
365
+ - github.com/joho/godotenv
366
+ callNames:
367
+ - godotenv.Load
368
+ - godotenv.Overload
369
+ - id: viper
370
+ importPaths:
371
+ - github.com/spf13/viper
372
+ callNames:
373
+ - viper.ReadInConfig
374
+ - viper.SetConfigName
375
+ - viper.AutomaticEnv
376
+ - id: envconfig
377
+ importPaths:
378
+ - github.com/kelseyhightower/envconfig
379
+ - github.com/caarlos0/env
380
+
381
+ configFile:
382
+ patternId: config_file
383
+ fileNameRegex: '(^|/)(config|configuration|settings)\.go$'
384
+ name: go_config
385
+ confidence: 0.75
386
+
387
+ external_apis:
388
+ httpClients:
389
+ - id: net_http_client
390
+ patternId: external_api_call
391
+ clientName: net_http
392
+ importPaths:
393
+ - net/http
394
+ callNames:
395
+ - http.Get
396
+ - http.Post
397
+ - http.PostForm
398
+ - http.Head
399
+ - http.NewRequest
400
+ - http.NewRequestWithContext
401
+ callNameSuffixes:
402
+ - .Do
403
+ urlRegex: '"(https?:\/\/[^\s"]+)"'
404
+ confidence: 0.85
405
+
406
+ - id: resty
407
+ patternId: external_api_call
408
+ clientName: resty
409
+ importPaths:
410
+ - github.com/go-resty/resty
411
+ callNames:
412
+ - resty.New
413
+ callNameSuffixes:
414
+ - .SetBaseURL
415
+ - .SetHostURL
416
+ urlRegex: '"(https?:\/\/[^\s"]+)"'
417
+ confidence: 0.85
418
+
419
+ - id: grpc_dial
420
+ patternId: external_api_call
421
+ clientName: grpc
422
+ importPaths:
423
+ - google.golang.org/grpc
424
+ callNames:
425
+ - grpc.Dial
426
+ - grpc.NewClient
427
+ - grpc.DialContext
428
+ urlRegex: '"([^"\s]+)"'
429
+ confidence: 0.8