attocode-code-intel 0.1.0__py3-none-any.whl

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 (345) hide show
  1. attocode_code_intel-0.1.0.dist-info/METADATA +221 -0
  2. attocode_code_intel-0.1.0.dist-info/RECORD +345 -0
  3. attocode_code_intel-0.1.0.dist-info/WHEEL +4 -0
  4. attocode_code_intel-0.1.0.dist-info/entry_points.txt +2 -0
  5. attocode_code_intel-0.1.0.dist-info/licenses/LICENSE +21 -0
  6. attocode_intel/GUIDELINES.md +432 -0
  7. attocode_intel/__init__.py +52 -0
  8. attocode_intel/_internal/__init__.py +1 -0
  9. attocode_intel/_internal/errors/__init__.py +126 -0
  10. attocode_intel/_internal/integrations/__init__.py +1 -0
  11. attocode_intel/_internal/integrations/context/__init__.py +1 -0
  12. attocode_intel/_internal/integrations/context/architecture_drift.py +354 -0
  13. attocode_intel/_internal/integrations/context/ast_chunker.py +202 -0
  14. attocode_intel/_internal/integrations/context/ast_service.py +1483 -0
  15. attocode_intel/_internal/integrations/context/blob_oid.py +423 -0
  16. attocode_intel/_internal/integrations/context/cache_manifest.py +221 -0
  17. attocode_intel/_internal/integrations/context/cas.py +466 -0
  18. attocode_intel/_internal/integrations/context/code_analyzer.py +528 -0
  19. attocode_intel/_internal/integrations/context/codebase_ast.py +1461 -0
  20. attocode_intel/_internal/integrations/context/codebase_context.py +1736 -0
  21. attocode_intel/_internal/integrations/context/cross_mode.py +263 -0
  22. attocode_intel/_internal/integrations/context/cross_references.py +616 -0
  23. attocode_intel/_internal/integrations/context/embedding_rotation.py +597 -0
  24. attocode_intel/_internal/integrations/context/embeddings.py +282 -0
  25. attocode_intel/_internal/integrations/context/frecency.py +427 -0
  26. attocode_intel/_internal/integrations/context/fuzzy.py +320 -0
  27. attocode_intel/_internal/integrations/context/hierarchical_explorer.py +331 -0
  28. attocode_intel/_internal/integrations/context/hydration.py +90 -0
  29. attocode_intel/_internal/integrations/context/index_repair.py +87 -0
  30. attocode_intel/_internal/integrations/context/index_store.py +586 -0
  31. attocode_intel/_internal/integrations/context/memory_store.py +602 -0
  32. attocode_intel/_internal/integrations/context/module_resolution.py +52 -0
  33. attocode_intel/_internal/integrations/context/query_constraints.py +361 -0
  34. attocode_intel/_internal/integrations/context/query_history.py +417 -0
  35. attocode_intel/_internal/integrations/context/reranker.py +351 -0
  36. attocode_intel/_internal/integrations/context/semantic_search.py +2931 -0
  37. attocode_intel/_internal/integrations/context/syntax_evidence.py +94 -0
  38. attocode_intel/_internal/integrations/context/systemone_ranker.py +245 -0
  39. attocode_intel/_internal/integrations/context/temporal_coupling.py +411 -0
  40. attocode_intel/_internal/integrations/context/trigram_index.py +820 -0
  41. attocode_intel/_internal/integrations/context/trigram_regex.py +171 -0
  42. attocode_intel/_internal/integrations/context/ts_parser.py +2199 -0
  43. attocode_intel/_internal/integrations/context/vector_store.py +795 -0
  44. attocode_intel/_internal/integrations/feature_flags/__init__.py +357 -0
  45. attocode_intel/_internal/integrations/lsp/__init__.py +1 -0
  46. attocode_intel/_internal/integrations/lsp/client.py +1140 -0
  47. attocode_intel/_internal/integrations/mcp/__init__.py +1 -0
  48. attocode_intel/_internal/integrations/mcp/client.py +253 -0
  49. attocode_intel/_internal/integrations/security/__init__.py +1 -0
  50. attocode_intel/_internal/integrations/security/custom_rules.py +176 -0
  51. attocode_intel/_internal/integrations/security/dataflow.py +522 -0
  52. attocode_intel/_internal/integrations/security/dependency_audit.py +303 -0
  53. attocode_intel/_internal/integrations/security/matcher.py +44 -0
  54. attocode_intel/_internal/integrations/security/patterns.py +724 -0
  55. attocode_intel/_internal/integrations/security/scanner.py +351 -0
  56. attocode_intel/_internal/integrations/utilities/__init__.py +1 -0
  57. attocode_intel/_internal/integrations/utilities/ignore.py +64 -0
  58. attocode_intel/_internal/integrations/utilities/token_estimate.py +51 -0
  59. attocode_intel/_internal/tricks/__init__.py +1 -0
  60. attocode_intel/_internal/tricks/recursive_context.py +357 -0
  61. attocode_intel/_internal/types/__init__.py +1 -0
  62. attocode_intel/_internal/types/events.py +289 -0
  63. attocode_intel/_internal/types/severity.py +15 -0
  64. attocode_intel/_shared.py +341 -0
  65. attocode_intel/analysis_coverage.py +56 -0
  66. attocode_intel/api/__init__.py +1 -0
  67. attocode_intel/api/access.py +32 -0
  68. attocode_intel/api/app.py +247 -0
  69. attocode_intel/api/auth/__init__.py +128 -0
  70. attocode_intel/api/auth/api_keys.py +61 -0
  71. attocode_intel/api/auth/context.py +34 -0
  72. attocode_intel/api/auth/jwt.py +66 -0
  73. attocode_intel/api/auth/oauth.py +146 -0
  74. attocode_intel/api/auth/passwords.py +15 -0
  75. attocode_intel/api/deps.py +351 -0
  76. attocode_intel/api/knowledge_bridge.py +13 -0
  77. attocode_intel/api/mcp_transport.py +51 -0
  78. attocode_intel/api/middleware.py +411 -0
  79. attocode_intel/api/models.py +698 -0
  80. attocode_intel/api/providers/__init__.py +1 -0
  81. attocode_intel/api/providers/db_provider.py +1106 -0
  82. attocode_intel/api/providers/local_provider.py +476 -0
  83. attocode_intel/api/providers/remote_provider.py +740 -0
  84. attocode_intel/api/repository_source.py +21 -0
  85. attocode_intel/api/routes/__init__.py +1 -0
  86. attocode_intel/api/routes/_pin_helper.py +158 -0
  87. attocode_intel/api/routes/activity.py +148 -0
  88. attocode_intel/api/routes/adr.py +102 -0
  89. attocode_intel/api/routes/analysis.py +515 -0
  90. attocode_intel/api/routes/api_keys.py +170 -0
  91. attocode_intel/api/routes/auth.py +428 -0
  92. attocode_intel/api/routes/branches.py +262 -0
  93. attocode_intel/api/routes/cross_repo_search.py +198 -0
  94. attocode_intel/api/routes/embeddings.py +386 -0
  95. attocode_intel/api/routes/files.py +132 -0
  96. attocode_intel/api/routes/files_v2.py +388 -0
  97. attocode_intel/api/routes/gc.py +322 -0
  98. attocode_intel/api/routes/git_v2.py +433 -0
  99. attocode_intel/api/routes/graph.py +174 -0
  100. attocode_intel/api/routes/graph_viz.py +160 -0
  101. attocode_intel/api/routes/health.py +62 -0
  102. attocode_intel/api/routes/history.py +175 -0
  103. attocode_intel/api/routes/jobs.py +84 -0
  104. attocode_intel/api/routes/learning.py +205 -0
  105. attocode_intel/api/routes/lsp.py +272 -0
  106. attocode_intel/api/routes/notify.py +623 -0
  107. attocode_intel/api/routes/operations.py +27 -0
  108. attocode_intel/api/routes/orgs.py +924 -0
  109. attocode_intel/api/routes/preferences.py +100 -0
  110. attocode_intel/api/routes/presence.py +42 -0
  111. attocode_intel/api/routes/projects.py +116 -0
  112. attocode_intel/api/routes/repos.py +47 -0
  113. attocode_intel/api/routes/search.py +180 -0
  114. attocode_intel/api/routes/snapshots.py +614 -0
  115. attocode_intel/api/routes/webhooks.py +313 -0
  116. attocode_intel/api/routes/websocket.py +116 -0
  117. attocode_intel/api/static/graph.html +239 -0
  118. attocode_intel/api/utils.py +96 -0
  119. attocode_intel/artifacts/__init__.py +45 -0
  120. attocode_intel/artifacts/hashing.py +230 -0
  121. attocode_intel/artifacts/provenance.py +190 -0
  122. attocode_intel/artifacts/retrieval_pin.py +159 -0
  123. attocode_intel/audit.py +59 -0
  124. attocode_intel/bug_finder.py +206 -0
  125. attocode_intel/bundle.py +80 -0
  126. attocode_intel/catalog.py +242 -0
  127. attocode_intel/change_review.py +75 -0
  128. attocode_intel/cli.py +3062 -0
  129. attocode_intel/community.py +63 -0
  130. attocode_intel/confidence/__init__.py +144 -0
  131. attocode_intel/confidence/jev.py +234 -0
  132. attocode_intel/confidence/llm.py +330 -0
  133. attocode_intel/confidence/redact.py +44 -0
  134. attocode_intel/confidence/settings.py +74 -0
  135. attocode_intel/config.py +256 -0
  136. attocode_intel/crypto.py +31 -0
  137. attocode_intel/db/__init__.py +7 -0
  138. attocode_intel/db/base.py +33 -0
  139. attocode_intel/db/engine.py +61 -0
  140. attocode_intel/db/models.py +529 -0
  141. attocode_intel/entrypoint.py +185 -0
  142. attocode_intel/focused_evidence.py +130 -0
  143. attocode_intel/freshness.py +154 -0
  144. attocode_intel/gateway.py +734 -0
  145. attocode_intel/git/__init__.py +7 -0
  146. attocode_intel/git/credentials.py +75 -0
  147. attocode_intel/git/manager.py +493 -0
  148. attocode_intel/git/models.py +96 -0
  149. attocode_intel/git/storage.py +98 -0
  150. attocode_intel/graph_query_parser.py +761 -0
  151. attocode_intel/helpers.py +712 -0
  152. attocode_intel/indexing/__init__.py +29 -0
  153. attocode_intel/indexing/debouncer.py +136 -0
  154. attocode_intel/indexing/delta_indexer.py +151 -0
  155. attocode_intel/indexing/full_indexer.py +323 -0
  156. attocode_intel/indexing/incremental.py +240 -0
  157. attocode_intel/indexing/parser.py +403 -0
  158. attocode_intel/indexing/summarizer.py +264 -0
  159. attocode_intel/installer.py +1896 -0
  160. attocode_intel/knowledge.py +269 -0
  161. attocode_intel/local_knowledge.py +77 -0
  162. attocode_intel/migrations/alembic.ini +36 -0
  163. attocode_intel/migrations/env.py +71 -0
  164. attocode_intel/migrations/script.py.mako +27 -0
  165. attocode_intel/migrations/versions/001_initial_schema.py +219 -0
  166. attocode_intel/migrations/versions/002_branch_version_and_embeddings.py +61 -0
  167. attocode_intel/migrations/versions/003_embedding_uniqueness_and_cascade.py +51 -0
  168. attocode_intel/migrations/versions/004_audit_events.py +38 -0
  169. attocode_intel/migrations/versions/005_user_preferences.py +30 -0
  170. attocode_intel/migrations/versions/006_google_oauth.py +27 -0
  171. attocode_intel/migrations/versions/007_pgvector_embeddings.py +28 -0
  172. attocode_intel/migrations/versions/008_symbol_references.py +37 -0
  173. attocode_intel/migrations/versions/009_webhook_secret_encryption.py +25 -0
  174. attocode_intel/migrations/versions/010_add_commits_table.py +40 -0
  175. attocode_intel/migrations/versions/011_commit_changed_files.py +25 -0
  176. attocode_intel/migrations/versions/012_branch_merged_at.py +25 -0
  177. attocode_intel/migrations/versions/013_revoked_tokens.py +32 -0
  178. attocode_intel/migrations/versions/014_blame_hunks.py +40 -0
  179. attocode_intel/migrations/versions/015_commit_file_stats.py +40 -0
  180. attocode_intel/migrations/versions/016_embedding_provenance_columns.py +179 -0
  181. attocode_intel/migrations/versions/017_provenance_table.py +102 -0
  182. attocode_intel/migrations/versions/018_repo_snapshots.py +178 -0
  183. attocode_intel/migrations/versions/019_symref_caller.py +42 -0
  184. attocode_intel/migrations/versions/020_shared_knowledge.py +29 -0
  185. attocode_intel/onboarding.py +258 -0
  186. attocode_intel/output.py +178 -0
  187. attocode_intel/precision.py +133 -0
  188. attocode_intel/presence.py +160 -0
  189. attocode_intel/probe.py +110 -0
  190. attocode_intel/project_dir.py +97 -0
  191. attocode_intel/pubsub.py +113 -0
  192. attocode_intel/query_ranking.py +242 -0
  193. attocode_intel/readiness.py +972 -0
  194. attocode_intel/redis.py +51 -0
  195. attocode_intel/reference_pages.py +60 -0
  196. attocode_intel/remote.py +131 -0
  197. attocode_intel/repo_ranker.py +246 -0
  198. attocode_intel/request_context.py +82 -0
  199. attocode_intel/rules/__init__.py +28 -0
  200. attocode_intel/rules/ci.py +320 -0
  201. attocode_intel/rules/combinators.py +293 -0
  202. attocode_intel/rules/enricher.py +127 -0
  203. attocode_intel/rules/evolution.py +452 -0
  204. attocode_intel/rules/executor.py +531 -0
  205. attocode_intel/rules/filters/__init__.py +5 -0
  206. attocode_intel/rules/filters/pipeline.py +151 -0
  207. attocode_intel/rules/formatter.py +198 -0
  208. attocode_intel/rules/hygiene.py +242 -0
  209. attocode_intel/rules/importers/__init__.py +1 -0
  210. attocode_intel/rules/importers/semgrep.py +382 -0
  211. attocode_intel/rules/loader.py +292 -0
  212. attocode_intel/rules/marketplace.py +375 -0
  213. attocode_intel/rules/metavar.py +181 -0
  214. attocode_intel/rules/model.py +317 -0
  215. attocode_intel/rules/packs/__init__.py +1 -0
  216. attocode_intel/rules/packs/community/_license_templates/Apache-2.0.txt +176 -0
  217. attocode_intel/rules/packs/community/_license_templates/MIT.txt +21 -0
  218. attocode_intel/rules/packs/community/bandit-python/LICENSE +176 -0
  219. attocode_intel/rules/packs/community/bandit-python/NOTICE +13 -0
  220. attocode_intel/rules/packs/community/bandit-python/PORTING.md +23 -0
  221. attocode_intel/rules/packs/community/bandit-python/manifest.yaml +14 -0
  222. attocode_intel/rules/packs/community/bandit-python/rules/B105-hardcoded-password.yaml +23 -0
  223. attocode_intel/rules/packs/community/bandit-python/rules/B303-weak-md5.yaml +21 -0
  224. attocode_intel/rules/packs/community/bandit-python/rules/B304-weak-des.yaml +20 -0
  225. attocode_intel/rules/packs/community/bandit-python/rules/B307-use-of-eval.yaml +22 -0
  226. attocode_intel/rules/packs/community/bandit-python/rules/B324-weak-sha1.yaml +21 -0
  227. attocode_intel/rules/packs/community/bandit-python/rules/B501-no-cert-validation.yaml +23 -0
  228. attocode_intel/rules/packs/community/bandit-python/rules/B602-shell-true.yaml +22 -0
  229. attocode_intel/rules/packs/community/bandit-python/rules/B608-sqli.yaml +22 -0
  230. attocode_intel/rules/packs/community/eslint-typescript/LICENSE +21 -0
  231. attocode_intel/rules/packs/community/eslint-typescript/NOTICE +13 -0
  232. attocode_intel/rules/packs/community/eslint-typescript/PORTING.md +23 -0
  233. attocode_intel/rules/packs/community/eslint-typescript/manifest.yaml +14 -0
  234. attocode_intel/rules/packs/community/eslint-typescript/rules/eqeqeq.yaml +20 -0
  235. attocode_intel/rules/packs/community/eslint-typescript/rules/no-eval.yaml +22 -0
  236. attocode_intel/rules/packs/community/eslint-typescript/rules/no-implied-eval.yaml +20 -0
  237. attocode_intel/rules/packs/community/eslint-typescript/rules/no-new-func.yaml +21 -0
  238. attocode_intel/rules/packs/community/eslint-typescript/rules/no-throw-literal.yaml +19 -0
  239. attocode_intel/rules/packs/community/eslint-typescript/rules/no-var.yaml +20 -0
  240. attocode_intel/rules/packs/community/eslint-typescript/rules/no-with.yaml +18 -0
  241. attocode_intel/rules/packs/community/gosec-go/LICENSE +176 -0
  242. attocode_intel/rules/packs/community/gosec-go/NOTICE +13 -0
  243. attocode_intel/rules/packs/community/gosec-go/PORTING.md +23 -0
  244. attocode_intel/rules/packs/community/gosec-go/manifest.yaml +14 -0
  245. attocode_intel/rules/packs/community/gosec-go/rules/G101-hardcoded-credentials.yaml +22 -0
  246. attocode_intel/rules/packs/community/gosec-go/rules/G102-bind-all-interfaces.yaml +21 -0
  247. attocode_intel/rules/packs/community/gosec-go/rules/G103-unsafe-block.yaml +21 -0
  248. attocode_intel/rules/packs/community/gosec-go/rules/G201-sql-format.yaml +21 -0
  249. attocode_intel/rules/packs/community/gosec-go/rules/G304-file-inclusion.yaml +23 -0
  250. attocode_intel/rules/packs/community/gosec-go/rules/G401-weak-cipher.yaml +20 -0
  251. attocode_intel/rules/packs/community/gosec-go/rules/G402-tls-min-version.yaml +20 -0
  252. attocode_intel/rules/packs/community/gosec-go/rules/G501-md5-import.yaml +21 -0
  253. attocode_intel/rules/packs/examples/cpp/manifest.yaml +4 -0
  254. attocode_intel/rules/packs/examples/cpp/rules/security.yaml +90 -0
  255. attocode_intel/rules/packs/examples/cpp/rules/structural.yaml +42 -0
  256. attocode_intel/rules/packs/examples/csharp/manifest.yaml +4 -0
  257. attocode_intel/rules/packs/examples/csharp/rules/security.yaml +69 -0
  258. attocode_intel/rules/packs/examples/csharp/rules/structural.yaml +42 -0
  259. attocode_intel/rules/packs/examples/go/manifest.yaml +4 -0
  260. attocode_intel/rules/packs/examples/go/rules/performance.yaml +136 -0
  261. attocode_intel/rules/packs/examples/go/rules/security.yaml +48 -0
  262. attocode_intel/rules/packs/examples/go/rules/structural.yaml +58 -0
  263. attocode_intel/rules/packs/examples/go/taint/sanitizers.yaml +24 -0
  264. attocode_intel/rules/packs/examples/go/taint/sinks.yaml +51 -0
  265. attocode_intel/rules/packs/examples/go/taint/sources.yaml +26 -0
  266. attocode_intel/rules/packs/examples/java/manifest.yaml +4 -0
  267. attocode_intel/rules/packs/examples/java/rules/correctness.yaml +55 -0
  268. attocode_intel/rules/packs/examples/java/rules/structural.yaml +48 -0
  269. attocode_intel/rules/packs/examples/java/taint/sinks.yaml +37 -0
  270. attocode_intel/rules/packs/examples/java/taint/sources.yaml +21 -0
  271. attocode_intel/rules/packs/examples/kotlin/manifest.yaml +4 -0
  272. attocode_intel/rules/packs/examples/kotlin/rules/correctness.yaml +50 -0
  273. attocode_intel/rules/packs/examples/kotlin/rules/structural.yaml +38 -0
  274. attocode_intel/rules/packs/examples/php/manifest.yaml +4 -0
  275. attocode_intel/rules/packs/examples/php/rules/security.yaml +66 -0
  276. attocode_intel/rules/packs/examples/php/rules/structural.yaml +41 -0
  277. attocode_intel/rules/packs/examples/python/manifest.yaml +4 -0
  278. attocode_intel/rules/packs/examples/python/rules/performance.yaml +90 -0
  279. attocode_intel/rules/packs/examples/python/rules/structural.yaml +55 -0
  280. attocode_intel/rules/packs/examples/ruby/manifest.yaml +4 -0
  281. attocode_intel/rules/packs/examples/ruby/rules/security.yaml +73 -0
  282. attocode_intel/rules/packs/examples/ruby/rules/structural.yaml +41 -0
  283. attocode_intel/rules/packs/examples/rust/manifest.yaml +4 -0
  284. attocode_intel/rules/packs/examples/rust/rules/correctness.yaml +51 -0
  285. attocode_intel/rules/packs/examples/rust/rules/structural.yaml +49 -0
  286. attocode_intel/rules/packs/examples/typescript/manifest.yaml +4 -0
  287. attocode_intel/rules/packs/examples/typescript/rules/performance.yaml +70 -0
  288. attocode_intel/rules/packs/examples/typescript/rules/structural.yaml +48 -0
  289. attocode_intel/rules/packs/pack_loader.py +244 -0
  290. attocode_intel/rules/plugins/__init__.py +1 -0
  291. attocode_intel/rules/plugins/plugin_loader.py +132 -0
  292. attocode_intel/rules/profiling.py +332 -0
  293. attocode_intel/rules/registry.py +213 -0
  294. attocode_intel/rules/sarif.py +187 -0
  295. attocode_intel/rules/synthesis.py +420 -0
  296. attocode_intel/rules/testing.py +326 -0
  297. attocode_intel/server.py +734 -0
  298. attocode_intel/service.py +3416 -0
  299. attocode_intel/sharing.py +57 -0
  300. attocode_intel/storage/__init__.py +6 -0
  301. attocode_intel/storage/branch_overlay.py +352 -0
  302. attocode_intel/storage/content_store.py +220 -0
  303. attocode_intel/storage/dependency_store.py +143 -0
  304. attocode_intel/storage/diff_engine.py +187 -0
  305. attocode_intel/storage/embedding_store.py +594 -0
  306. attocode_intel/storage/provenance_store.py +137 -0
  307. attocode_intel/storage/security_scanner_db.py +164 -0
  308. attocode_intel/storage/symbol_store.py +160 -0
  309. attocode_intel/structural_evidence.py +144 -0
  310. attocode_intel/symbol_inspection.py +141 -0
  311. attocode_intel/symbol_links.py +167 -0
  312. attocode_intel/telemetry.py +42 -0
  313. attocode_intel/test_ranking.py +73 -0
  314. attocode_intel/testing/__init__.py +43 -0
  315. attocode_intel/testing/fixtures.py +122 -0
  316. attocode_intel/testing/helpers.py +75 -0
  317. attocode_intel/testing/mocks.py +99 -0
  318. attocode_intel/tools/__init__.py +2 -0
  319. attocode_intel/tools/adr_tools.py +628 -0
  320. attocode_intel/tools/analysis_tools.py +382 -0
  321. attocode_intel/tools/composite_tools.py +695 -0
  322. attocode_intel/tools/cross_mode_tools.py +173 -0
  323. attocode_intel/tools/dead_code_tools.py +582 -0
  324. attocode_intel/tools/distill_tools.py +353 -0
  325. attocode_intel/tools/frecency_tools.py +220 -0
  326. attocode_intel/tools/fuzzy_tools.py +255 -0
  327. attocode_intel/tools/history_tools.py +486 -0
  328. attocode_intel/tools/learning_tools.py +222 -0
  329. attocode_intel/tools/lsp_tools.py +218 -0
  330. attocode_intel/tools/maintenance_tools.py +1662 -0
  331. attocode_intel/tools/navigation_tools.py +220 -0
  332. attocode_intel/tools/overlay_tools.py +540 -0
  333. attocode_intel/tools/pin_store.py +432 -0
  334. attocode_intel/tools/pin_tools.py +266 -0
  335. attocode_intel/tools/query_constraints_tools.py +262 -0
  336. attocode_intel/tools/query_history_tools.py +158 -0
  337. attocode_intel/tools/readiness_tools.py +44 -0
  338. attocode_intel/tools/rule_tools.py +992 -0
  339. attocode_intel/tools/search_tools.py +770 -0
  340. attocode_intel/tools/snapshot_tools.py +624 -0
  341. attocode_intel/workers/__init__.py +1 -0
  342. attocode_intel/workers/job_utils.py +111 -0
  343. attocode_intel/workers/jobs.py +573 -0
  344. attocode_intel/workers/run.py +30 -0
  345. attocode_intel/workers/settings.py +61 -0
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Support. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or support.
175
+
176
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,13 @@
1
+ # NOTICE — gosec-go
2
+
3
+ Rule patterns adapted from gosec (https://github.com/securego/gosec). Original copyright securego authors. Licensed under Apache-2.0.
4
+
5
+ Upstream: https://github.com/securego/gosec
6
+ Commit: (unspecified)
7
+ License: Apache-2.0
8
+
9
+ Modifications:
10
+ - Translated rule patterns to attocode UnifiedRule schema
11
+ - Subset selection (high-value rules first)
12
+
13
+ See LICENSE for full license terms.
@@ -0,0 +1,23 @@
1
+ # Porting checklist — gosec-go
2
+
3
+ Rules from gosec (https://github.com/securego/gosec) are not YAML-defined upstream
4
+ and require manual porting. Each ported rule MUST include the
5
+ attribution comment header at the top of its YAML file:
6
+
7
+ ```yaml
8
+ # Adapted from gosec rule '<original-id>'
9
+ # See ../LICENSE and ../NOTICE for license terms.
10
+ ```
11
+
12
+ Porting targets:
13
+
14
+ - [ ] G101 hardcoded_credentials
15
+ - [ ] G102 bind_to_all_interfaces
16
+ - [ ] G103 unsafe_block
17
+ - [ ] G201 sql_format_string
18
+ - [ ] G203 unescaped_template_data
19
+ - [ ] G304 file_path_inclusion
20
+ - [ ] G401 weak_des_or_rc4_crypto
21
+ - [ ] G402 tls_min_version
22
+ - [ ] G501 weak_md5_hash
23
+ - [ ] G505 weak_sha1_hash
@@ -0,0 +1,14 @@
1
+ name: gosec-go
2
+ version: 1.0.0
3
+ languages:
4
+ - go
5
+ description: Hand-ported subset of gosec rules. See PORTING.md for the porting checklist.
6
+ source: community
7
+ source_url: https://github.com/securego/gosec
8
+ source_commit: ''
9
+ source_license: Apache-2.0
10
+ attribution: Rule patterns adapted from gosec (https://github.com/securego/gosec).
11
+ Original copyright securego authors. Licensed under Apache-2.0.
12
+ imported_at: '2026-04-16T12:20:09Z'
13
+ upstream_rule_count: 10
14
+ imported_rule_count: 0
@@ -0,0 +1,22 @@
1
+ # Adapted from gosec rule 'G101 hardcoded_credentials'
2
+ # See ../LICENSE and ../NOTICE for license terms.
3
+
4
+ id: G101-hardcoded-credentials
5
+ name: Hardcoded credentials in source
6
+ message: Possible hardcoded credential in source
7
+ severity: high
8
+ category: security
9
+ languages: [go]
10
+ confidence: 0.7
11
+ cwe: CWE-798
12
+ pattern: '(?i)(password|passwd|pwd|secret|token|apikey|api_key)\s*[:=]\s*"[^"]{4,}"'
13
+ explanation: |
14
+ Storing credentials in Go source — whether as struct fields, package
15
+ vars, or const literals — leaks them to anyone with read access to the
16
+ binary or repo.
17
+ recommendation: |
18
+ Read secrets from env vars (``os.Getenv``), KMS, Vault, or Kubernetes
19
+ secrets at runtime.
20
+ references:
21
+ - https://github.com/securego/gosec
22
+ - https://cwe.mitre.org/data/definitions/798.html
@@ -0,0 +1,21 @@
1
+ # Adapted from gosec rule 'G102 bind_to_all_interfaces'
2
+ # See ../LICENSE and ../NOTICE for license terms.
3
+
4
+ id: G102-bind-all-interfaces
5
+ name: Bind to all network interfaces
6
+ message: Service bound to 0.0.0.0 — exposes all network interfaces
7
+ severity: medium
8
+ category: security
9
+ languages: [go]
10
+ confidence: 0.75
11
+ cwe: CWE-200
12
+ pattern: '"0\.0\.0\.0:'
13
+ explanation: |
14
+ Binding to ``0.0.0.0`` makes the service reachable on every network
15
+ interface (including public IPs). Often unintended, especially in
16
+ development services that should be loopback-only.
17
+ recommendation: |
18
+ Bind to ``127.0.0.1`` for local-only services. For services that need
19
+ external access, document the exposure and pair with firewall rules.
20
+ references:
21
+ - https://github.com/securego/gosec
@@ -0,0 +1,21 @@
1
+ # Adapted from gosec rule 'G103 unsafe_block'
2
+ # See ../LICENSE and ../NOTICE for license terms.
3
+
4
+ id: G103-unsafe-block
5
+ name: Use of unsafe package
6
+ message: Package 'unsafe' bypasses Go type safety
7
+ severity: medium
8
+ category: suspicious
9
+ languages: [go]
10
+ confidence: 0.85
11
+ pattern: '\bunsafe\.(Pointer|Sizeof|Alignof|Offsetof|String|StringData|Slice|SliceData)\b'
12
+ explanation: |
13
+ ``unsafe`` lets you bypass Go's type system and memory-safety
14
+ guarantees. Code paths that touch ``unsafe`` need extra review for
15
+ data-race, alignment, and pointer-aliasing bugs.
16
+ recommendation: |
17
+ Audit each ``unsafe`` call site. Document why type safety must be
18
+ bypassed and which invariants the surrounding code maintains.
19
+ references:
20
+ - https://github.com/securego/gosec
21
+ - https://pkg.go.dev/unsafe
@@ -0,0 +1,21 @@
1
+ # Adapted from gosec rule 'G201 sql_format_string'
2
+ # See ../LICENSE and ../NOTICE for license terms.
3
+
4
+ id: G201-sql-format
5
+ name: SQL string built via fmt.Sprintf
6
+ message: SQL built with fmt.Sprintf — possible injection
7
+ severity: high
8
+ category: security
9
+ languages: [go]
10
+ confidence: 0.7
11
+ cwe: CWE-89
12
+ pattern: '\bfmt\.Sprintf\s*\(\s*"[^"]*\b(SELECT|INSERT|UPDATE|DELETE)\b'
13
+ explanation: |
14
+ ``fmt.Sprintf`` formats values without SQL escaping. Any user-supplied
15
+ string in the format args can break the query and inject statements.
16
+ recommendation: |
17
+ Use ``db.Exec(query, args...)`` / ``db.Query(query, args...)`` with
18
+ positional placeholders (``$1``, ``?``) so the driver handles escaping.
19
+ references:
20
+ - https://github.com/securego/gosec
21
+ - https://cwe.mitre.org/data/definitions/89.html
@@ -0,0 +1,23 @@
1
+ # Adapted from gosec rule 'G304 file_path_inclusion'
2
+ # See ../LICENSE and ../NOTICE for license terms.
3
+
4
+ id: G304-file-inclusion
5
+ name: Variable file path passed to file IO
6
+ message: Tainted file path — possible directory traversal
7
+ severity: medium
8
+ category: security
9
+ languages: [go]
10
+ confidence: 0.55
11
+ cwe: CWE-22
12
+ pattern: '\bos\.(Open|ReadFile|Create|OpenFile)\s*\(\s*[a-zA-Z_]\w*\s*[,)]'
13
+ explanation: |
14
+ Reading or writing to a file path that comes from a variable (rather
15
+ than a const) risks directory traversal if the variable is influenced
16
+ by user input.
17
+ recommendation: |
18
+ Validate the path against an allowlist or wrap with ``filepath.Clean``
19
+ + ``filepath.Rel`` to confirm the result stays within the intended
20
+ base directory.
21
+ references:
22
+ - https://github.com/securego/gosec
23
+ - https://cwe.mitre.org/data/definitions/22.html
@@ -0,0 +1,20 @@
1
+ # Adapted from gosec rule 'G401 weak_des_or_rc4_crypto'
2
+ # See ../LICENSE and ../NOTICE for license terms.
3
+
4
+ id: G401-weak-cipher
5
+ name: Use of weak cipher (DES/RC4)
6
+ message: DES and RC4 are cryptographically weak
7
+ severity: high
8
+ category: security
9
+ languages: [go]
10
+ confidence: 0.85
11
+ cwe: CWE-327
12
+ pattern: '\b(des|rc4)\.New(?:Cipher|TripleDESCipher)?\s*\('
13
+ explanation: |
14
+ ``crypto/des`` and ``crypto/rc4`` are obsolete. DES has a 56-bit key
15
+ (brute-forceable); RC4 has known biases.
16
+ recommendation: |
17
+ Use ``crypto/aes`` with GCM mode for symmetric encryption.
18
+ references:
19
+ - https://github.com/securego/gosec
20
+ - https://pkg.go.dev/crypto/aes
@@ -0,0 +1,20 @@
1
+ # Adapted from gosec rule 'G402 tls_min_version'
2
+ # See ../LICENSE and ../NOTICE for license terms.
3
+
4
+ id: G402-tls-min-version
5
+ name: TLS MinVersion below TLS 1.2
6
+ message: TLS configured with old protocol version (SSLv3/TLS1.0/TLS1.1)
7
+ severity: high
8
+ category: security
9
+ languages: [go]
10
+ confidence: 0.85
11
+ cwe: CWE-326
12
+ pattern: '\bMinVersion\s*:\s*tls\.Version(SSL30|TLS10|TLS11)\b'
13
+ explanation: |
14
+ TLS 1.0/1.1 and SSL 3.0 have known vulnerabilities (BEAST, POODLE,
15
+ Lucky13). Modern services should require TLS 1.2 or 1.3.
16
+ recommendation: |
17
+ Use ``MinVersion: tls.VersionTLS12`` (or ``VersionTLS13``).
18
+ references:
19
+ - https://github.com/securego/gosec
20
+ - https://cwe.mitre.org/data/definitions/326.html
@@ -0,0 +1,21 @@
1
+ # Adapted from gosec rule 'G501 weak_md5_hash'
2
+ # See ../LICENSE and ../NOTICE for license terms.
3
+
4
+ id: G501-md5-import
5
+ name: Import of crypto/md5
6
+ message: crypto/md5 is cryptographically broken
7
+ severity: medium
8
+ category: security
9
+ languages: [go]
10
+ confidence: 0.7
11
+ cwe: CWE-327
12
+ pattern: '"crypto/md5"'
13
+ explanation: |
14
+ MD5 is vulnerable to collision attacks. Importing ``crypto/md5`` is a
15
+ smell — even when the use is intentional, it's worth a comment
16
+ explaining why.
17
+ recommendation: |
18
+ Use ``crypto/sha256`` for hashing. If MD5 is needed for non-security
19
+ reasons (legacy file formats, etag compatibility), document why.
20
+ references:
21
+ - https://github.com/securego/gosec
@@ -0,0 +1,4 @@
1
+ name: cpp
2
+ version: 1.0.0
3
+ languages: [c, cpp]
4
+ description: "C / C++ analysis pack — memory safety, deprecated APIs, idiomatic style"
@@ -0,0 +1,90 @@
1
+ # C / C++ memory-safety and deprecated-API rules (Tier 1 regex).
2
+
3
+ - id: cpp-strcpy-unsafe
4
+ name: Unsafe strcpy call
5
+ pattern: '\bstrcpy\s*\('
6
+ message: "strcpy has no bounds check — overflows the destination on long input"
7
+ severity: high
8
+ category: security
9
+ languages: [c, cpp]
10
+ cwe: CWE-120
11
+ confidence: 0.85
12
+ explanation: >
13
+ ``strcpy`` keeps copying until it hits a NUL terminator with no
14
+ knowledge of the destination buffer's size. Long source strings
15
+ overflow whatever follows on the stack/heap.
16
+ recommendation: "Use strncpy_s, strlcpy, or std::string for guaranteed-bounded copies."
17
+ examples:
18
+ - bad: "char buf[16];\nstrcpy(buf, user_input);"
19
+ good: "char buf[16];\nstrlcpy(buf, user_input, sizeof(buf));"
20
+ explanation: "strlcpy refuses to write past the destination size."
21
+
22
+ - id: cpp-strcat-unsafe
23
+ name: Unsafe strcat call
24
+ pattern: '\bstrcat\s*\('
25
+ message: "strcat has no bounds check — overflows the destination if strlen(dst)+strlen(src) >= cap"
26
+ severity: high
27
+ category: security
28
+ languages: [c, cpp]
29
+ cwe: CWE-120
30
+ confidence: 0.85
31
+ recommendation: "Use strlcat or std::string concatenation with explicit size checks."
32
+
33
+ - id: cpp-gets-banned
34
+ name: gets() called
35
+ pattern: '\bgets\s*\('
36
+ message: "gets() reads unbounded input — removed from C11 entirely"
37
+ severity: critical
38
+ category: security
39
+ languages: [c, cpp]
40
+ cwe: CWE-242
41
+ confidence: 0.99
42
+ explanation: >
43
+ ``gets`` cannot be used safely under any circumstances; it was
44
+ removed from the C11 standard. Always reads until newline with no
45
+ way to limit length.
46
+ recommendation: "Use fgets(buf, sizeof(buf), stdin) instead."
47
+
48
+ - id: cpp-sprintf-unsafe
49
+ name: sprintf without bounds check
50
+ pattern: '\bsprintf\s*\('
51
+ message: "sprintf cannot bound its output — use snprintf with the buffer size"
52
+ severity: high
53
+ category: security
54
+ languages: [c, cpp]
55
+ cwe: CWE-120
56
+ confidence: 0.7
57
+ recommendation: "Use snprintf(buf, sizeof(buf), \"...\", ...) so the output is truncated rather than overflowing."
58
+
59
+ - id: cpp-system-call
60
+ name: system() invokes the shell
61
+ pattern: '\bsystem\s*\('
62
+ message: "system() runs through the shell — risk of command injection if any arg is attacker-controlled"
63
+ severity: high
64
+ category: security
65
+ languages: [c, cpp]
66
+ cwe: CWE-78
67
+ confidence: 0.7
68
+ recommendation: "Use execve/posix_spawn with argv arrays so arguments aren't shell-parsed."
69
+
70
+ - id: cpp-md5-deprecated
71
+ name: MD5 used for security purposes
72
+ pattern: '\bMD5(?:_Init|_Update|_Final|\s*\()'
73
+ message: "MD5 is cryptographically broken — use SHA-256 or BLAKE3 for new code"
74
+ severity: medium
75
+ category: security
76
+ languages: [c, cpp]
77
+ cwe: CWE-327
78
+ confidence: 0.7
79
+ recommendation: "Use SHA-256 (EVP_sha256) or BLAKE3 for hashing; bcrypt/argon2 for passwords."
80
+
81
+ - id: cpp-rand-non-crypto
82
+ name: rand() used where crypto strength is needed
83
+ pattern: '\brand\s*\(\s*\)'
84
+ message: "rand() is not cryptographically secure — predictable from a few outputs"
85
+ severity: low
86
+ category: security
87
+ languages: [c, cpp]
88
+ cwe: CWE-338
89
+ confidence: 0.4
90
+ recommendation: "For security-sensitive randomness use /dev/urandom, getrandom(), or std::random_device."
@@ -0,0 +1,42 @@
1
+ # C / C++ structural patterns (ast-grep, Tier 2).
2
+
3
+ - id: cpp-printf-debug
4
+ name: printf debug leftover
5
+ structural_pattern: 'printf($$$X)'
6
+ structural_context: 'void _f() { printf($$$X); }'
7
+ structural_selector: call_expression
8
+ message: "printf — debug leftover, route through proper logging"
9
+ severity: low
10
+ category: style
11
+ languages: [c, cpp]
12
+ confidence: 0.35
13
+ tags: [debug]
14
+ explanation: >
15
+ Bare ``printf`` calls aren't filtered by level and bypass any logging
16
+ pipeline. In libraries especially, leaking to stdout is surprising.
17
+ recommendation: "Use a logging framework (spdlog, glog) or remove if it was a debug aid."
18
+
19
+ - id: cpp-cout-debug
20
+ name: std::cout debug leftover
21
+ structural_pattern: 'std::cout << $X'
22
+ message: "std::cout << $X — debug leftover, prefer a logger in non-CLI code"
23
+ severity: low
24
+ category: style
25
+ languages: [cpp]
26
+ confidence: 0.35
27
+ tags: [debug]
28
+ recommendation: "Use spdlog/glog for filterable output; remove if it was a debug aid."
29
+
30
+ - id: cpp-c-style-cast
31
+ name: C-style cast in C++
32
+ structural_pattern: '($T)$EXPR'
33
+ message: "C-style cast — prefer static_cast / reinterpret_cast / const_cast for clearer intent"
34
+ severity: low
35
+ category: style
36
+ languages: [cpp]
37
+ confidence: 0.3
38
+ explanation: >
39
+ C-style casts collapse static_cast, reinterpret_cast, and const_cast
40
+ into one syntax. The C++ named casts make the kind of conversion
41
+ explicit and let the compiler check semantics.
42
+ recommendation: "Use static_cast<T>(expr), reinterpret_cast<T>(expr), or const_cast<T>(expr)."
@@ -0,0 +1,4 @@
1
+ name: csharp
2
+ version: 1.0.0
3
+ languages: [csharp]
4
+ description: "C# analysis pack — security, async pitfalls, idiomatic .NET style"
@@ -0,0 +1,69 @@
1
+ # C# security and correctness rules (Tier 1 regex).
2
+
3
+ - id: csharp-md5-deprecated
4
+ name: MD5 used for security purposes
5
+ pattern: '\bMD5(?:CryptoServiceProvider|\.Create)\b'
6
+ message: "MD5 is broken for security — use SHA256 or BCrypt for new code"
7
+ severity: medium
8
+ category: security
9
+ languages: [csharp]
10
+ cwe: CWE-327
11
+ confidence: 0.8
12
+ recommendation: "Use SHA256.Create() for hashing; BCrypt.Net for password storage."
13
+
14
+ - id: csharp-sha1-deprecated
15
+ name: SHA-1 used for security purposes
16
+ pattern: '\bSHA1(?:CryptoServiceProvider|\.Create)\b'
17
+ message: "SHA-1 is broken for collision resistance — use SHA256 instead"
18
+ severity: medium
19
+ category: security
20
+ languages: [csharp]
21
+ cwe: CWE-327
22
+ confidence: 0.8
23
+ recommendation: "Use SHA256.Create()."
24
+
25
+ - id: csharp-process-start-shell
26
+ name: Process.Start with concatenated arguments
27
+ pattern: 'Process\.Start\s*\([^,)]*\+[^)]+\)'
28
+ message: "Process.Start with string concat — risk of command injection"
29
+ severity: high
30
+ category: security
31
+ languages: [csharp]
32
+ cwe: CWE-78
33
+ confidence: 0.55
34
+ recommendation: "Use ProcessStartInfo with ArgumentList so each arg is escaped individually."
35
+
36
+ - id: csharp-sql-string-concat
37
+ name: SQL query built via string concat
38
+ pattern: 'new\s+SqlCommand\s*\([^)]*\+'
39
+ message: "SqlCommand with concatenated SQL — use parameterized queries"
40
+ severity: high
41
+ category: security
42
+ languages: [csharp]
43
+ cwe: CWE-89
44
+ confidence: 0.7
45
+ recommendation: "Use cmd.Parameters.AddWithValue(\"@name\", value) to pass user input."
46
+
47
+ - id: csharp-empty-catch
48
+ name: Empty catch swallows exceptions
49
+ pattern: 'catch\s*\([^)]*\)\s*\{\s*\}'
50
+ message: "Empty catch block silently swallows the exception — at least log it"
51
+ severity: medium
52
+ category: correctness
53
+ languages: [csharp]
54
+ confidence: 0.85
55
+ recommendation: "Log the exception (Logger.LogError(ex, \"...\")) or rethrow."
56
+
57
+ - id: csharp-task-result-blocking
58
+ name: .Result on a Task
59
+ pattern: '\.Result\b(?![a-zA-Z_])'
60
+ message: ".Result blocks the calling thread and can deadlock — await the task"
61
+ severity: medium
62
+ category: correctness
63
+ languages: [csharp]
64
+ confidence: 0.5
65
+ explanation: >
66
+ Calling ``.Result`` on a Task blocks the thread until completion.
67
+ In UI/ASP.NET sync contexts this can deadlock when the awaited
68
+ continuation needs the same thread. Always prefer ``await``.
69
+ recommendation: "Use 'await task' in async methods, or Task.Run(...).GetAwaiter().GetResult() at the boundary."
@@ -0,0 +1,42 @@
1
+ # C# structural patterns (ast-grep, Tier 2).
2
+
3
+ - id: csharp-console-writeline-debug
4
+ name: Console.WriteLine debug leftover
5
+ structural_pattern: 'Console.WriteLine($X)'
6
+ message: "Console.WriteLine($X) — debug leftover, route through ILogger"
7
+ severity: low
8
+ category: style
9
+ languages: [csharp]
10
+ confidence: 0.35
11
+ tags: [debug]
12
+ explanation: >
13
+ ``Console.WriteLine`` bypasses the logging framework: no levels,
14
+ no MDC, no shipping to log aggregators. In service code prefer the
15
+ injected ``ILogger`` so output respects the configured pipeline.
16
+ recommendation: "Use ILogger.LogInformation(\"...\", arg) or remove if it was a debug aid."
17
+
18
+ - id: csharp-throw-generic-exception
19
+ name: throw new Exception(...) — too generic
20
+ structural_pattern: 'throw new Exception($X)'
21
+ message: "throw new Exception($X) — use a more specific exception type"
22
+ severity: medium
23
+ category: correctness
24
+ languages: [csharp]
25
+ confidence: 0.7
26
+ explanation: >
27
+ Throwing the base ``Exception`` forces callers to catch the world.
28
+ Specific exception types (ArgumentException, InvalidOperationException,
29
+ domain-specific subclasses) communicate what went wrong and let
30
+ callers handle each case appropriately.
31
+ recommendation: "Throw ArgumentException, InvalidOperationException, or a domain-specific subclass."
32
+
33
+ - id: csharp-string-format-debug
34
+ name: Debug string.Format with constants
35
+ structural_pattern: 'string.Format($FMT, $$$ARGS)'
36
+ message: "string.Format($FMT, ...) — interpolated strings ($\"...\") read clearer"
37
+ severity: info
38
+ category: style
39
+ languages: [csharp]
40
+ confidence: 0.3
41
+ tags: [style]
42
+ recommendation: "Prefer interpolated strings: $\"Hello {name}\" over string.Format(\"Hello {0}\", name)."