Skip to content

Commit 624196a

Browse files
aksOpsclaude
andcommitted
Fix all review issues: security, determinism, infra, docs, frontend
Security: - Cypher injection: replace startsWith blocklist with contains-based check, add REMOVE/FOREACH/LOAD CSV, no tx.commit() (read-only defense-in-depth) - POST /api/analyze: add AtomicBoolean concurrency guard (409 Conflict) Determinism: - TopicLinker/ModuleContainmentLinker/EntityLinker: HashMap → TreeMap - GraphBuilder: track droppedEdgeCount, getEdgeCount() excludes dropped edges Robustness: - AbstractAntlrDetector + Analyzer: catch Throwable (not just Exception) to handle ANTLR StackOverflowError on adversarial input - Analyzer: executor created once before batch loop, not per-batch Infrastructure: - Dockerfile: install curl for HEALTHCHECK - Helm: PVC for graph data (replaces emptyDir), configurable persistence - application.yml: enable K8s liveness/readiness health probes Documentation: - CLAUDE.md: fix 7 SQLite→H2 refs, detector count 106→97, CLI 12→14, NodeKind 31→32, EdgeKind 26→27 - README.md: fix SonarCloud badge project key - CI workflows: remove deleted java branch from triggers - pom.xml: SCM URL tree/java → tree/main Frontend: - DOMPurify 3.2.7→3.3.3 (fixes 2 XSS vulnerabilities), 0 audit issues - SpaController: add /dashboard route + catch-all for React Router Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 777ed98 commit 624196a

24 files changed

Lines changed: 131 additions & 68 deletions

File tree

.github/workflows/ci-java.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
name: Java CI
22
on:
33
push:
4-
branches: [main, java]
4+
branches: [main]
55
paths: ['src/**', 'pom.xml']
66
pull_request:
7-
branches: [main, java]
7+
branches: [main]
88

99
jobs:
1010
build:

.github/workflows/sonarcloud-java.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
name: SonarCloud Java
22
on:
33
push:
4-
branches: [main, java]
4+
branches: [main]
55
paths: ['src/**', 'pom.xml']
66
pull_request:
7-
branches: [main, java]
7+
branches: [main]
88

99
jobs:
1010
sonar:

CLAUDE.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
## What This Project Is
44

5-
**OSSCodeIQ** -- a CLI tool + server that scans codebases to build a deterministic code knowledge graph. No AI, no external APIs -- pure static analysis. 106 detectors, 35+ languages, Neo4j Embedded graph database, Hazelcast distributed cache, Spring AI MCP server, REST API, web UI.
5+
**OSSCodeIQ** -- a CLI tool + server that scans codebases to build a deterministic code knowledge graph. No AI, no external APIs -- pure static analysis. 97 detectors, 35+ languages, Neo4j Embedded graph database, Hazelcast distributed cache, Spring AI MCP server, REST API, web UI.
66

77
- **Maven coordinates:** `io.github.randomcodespace.iq:code-iq`
88
- **CLI command:** `code-iq` (via `java -jar`)
99
- **Java package:** `io.github.randomcodespace.iq` (under `src/main/java/`)
1010
- **GitHub repo:** `RandomCodeSpace/code-iq` (branch: `java`)
11-
- **Cache directory on disk:** `.code-intelligence` (SQLite analysis cache)
11+
- **Cache directory on disk:** `.code-intelligence` (H2 analysis cache)
1212
- **Config file:** `.osscodeiq.yml` (project-level overrides)
1313

1414
## Tech Stack
@@ -22,7 +22,7 @@
2222
- ANTLR 4.13.2 (TypeScript/JavaScript, Python, Go, C#, Rust, C++ grammars)
2323
- Picocli 4.7.7 (CLI framework, integrated with Spring Boot)
2424
- Thymeleaf + HTMX (web UI)
25-
- SQLite JDBC (incremental analysis cache)
25+
- H2 (incremental analysis cache)
2626

2727
## Architecture
2828

@@ -43,7 +43,7 @@ FileDiscovery --> Parsers --> Detectors (virtual threads) --> GraphBuilder (buff
4343
- **Linkers** -- run after all detectors: `TopicLinker`, `EntityLinker`, `ModuleContainmentLinker`
4444
- **LayerClassifier** -- sets `layer` property on every node: `frontend | backend | infra | shared | unknown`
4545
- **GraphStore** -- facade over Neo4j, delegates Cypher operations
46-
- **AnalysisCache** -- SQLite-backed file hash cache for incremental analysis
46+
- **AnalysisCache** -- H2-backed file hash cache for incremental analysis
4747

4848
### Spring Profiles
4949
- **`indexing`** -- active during CLI analyze/stats/graph/query/find/flow/bundle/cache/plugins commands. Starts Neo4j Embedded, runs analysis pipeline.
@@ -57,8 +57,8 @@ io.github.randomcodespace.iq
5757
|-- analyzer/ # Pipeline: Analyzer, FileDiscovery, GraphBuilder, LayerClassifier
5858
| |-- linker/ # Cross-file linkers: TopicLinker, EntityLinker, ModuleContainmentLinker
5959
|-- api/ # REST controllers: GraphController, FlowController
60-
|-- cache/ # AnalysisCache (SQLite), FileHasher
61-
|-- cli/ # Picocli commands (12 commands + CodeIqCli parent + CliOutput helper)
60+
|-- cache/ # AnalysisCache (H2), FileHasher
61+
|-- cli/ # Picocli commands (14 commands + CodeIqCli parent + CliOutput helper)
6262
|-- config/ # Spring config: Neo4jConfig, HazelcastConfig, CodeIqConfig, JacksonConfig
6363
|-- detector/ # Detector interface + 97 concrete detectors
6464
| |-- auth/ # LDAP, certificate, session/header auth
@@ -84,7 +84,7 @@ io.github.randomcodespace.iq
8484
|-- graph/ # GraphStore (facade), GraphRepository (Spring Data Neo4j)
8585
|-- health/ # GraphHealthIndicator (Spring Actuator)
8686
|-- mcp/ # McpTools (21 Spring AI @Tool methods)
87-
|-- model/ # CodeNode, CodeEdge, NodeKind (31), EdgeKind (26)
87+
|-- model/ # CodeNode, CodeEdge, NodeKind (32), EdgeKind (27)
8888
|-- query/ # QueryService (graph queries), StatsService (categorized stats)
8989
|-- web/ # ExplorerController (Thymeleaf web UI)
9090
```
@@ -104,7 +104,7 @@ io.github.randomcodespace.iq
104104

105105
### Virtual Thread Safety
106106
- All file I/O and Neo4j operations run on virtual threads
107-
- The SQLite analysis cache uses `synchronized` blocks for thread safety
107+
- The H2 analysis cache uses `synchronized` blocks for thread safety
108108
- Hazelcast cache operations are thread-safe by design
109109
- Detectors MUST be stateless -- Spring `@Component` beans are singletons
110110

@@ -239,8 +239,8 @@ mvn checkstyle:check
239239
| `detector/AbstractRegexDetector.java` | Base class for regex detectors |
240240
| `detector/AbstractJavaParserDetector.java` | Base class for JavaParser-based detectors |
241241
| `detector/AbstractAntlrDetector.java` | Base class for ANTLR-based detectors |
242-
| `model/NodeKind.java` | 31 node types enum |
243-
| `model/EdgeKind.java` | 26 edge types enum |
242+
| `model/NodeKind.java` | 32 node types enum |
243+
| `model/EdgeKind.java` | 27 edge types enum |
244244
| `model/CodeNode.java` | Graph node entity (Spring Data Neo4j) |
245245
| `model/CodeEdge.java` | Graph edge entity (Spring Data Neo4j) |
246246
| `graph/GraphStore.java` | Neo4j facade |
@@ -249,7 +249,7 @@ mvn checkstyle:check
249249
| `config/HazelcastConfig.java` | Hazelcast cache configuration |
250250
| `config/CodeIqConfig.java` | Application configuration properties |
251251
| `config/ProjectConfigLoader.java` | Loads .osscodeiq.yml overrides |
252-
| `cache/AnalysisCache.java` | SQLite incremental cache |
252+
| `cache/AnalysisCache.java` | H2 incremental cache |
253253
| `api/GraphController.java` | REST API endpoints |
254254
| `api/FlowController.java` | Flow diagram endpoints |
255255
| `mcp/McpTools.java` | 21 MCP tool definitions (Spring AI @Tool) |
@@ -291,7 +291,7 @@ Placed in the codebase root, loaded by `ProjectConfigLoader` before analysis.
291291
- **Neo4j deprecation warnings**: `CodeEdge` uses Long IDs (deprecated). Plan to migrate to external IDs.
292292
- **MCP warnings in CLI mode**: "No tool/resource/prompt/complete methods found" -- expected when not in `serving` profile.
293293
- **XML DOCTYPE warnings**: Non-fatal stderr from XML parser encountering DOCTYPE declarations.
294-
- **Virtual thread pinning**: SQLite JDBC operations can pin carrier threads. Use `synchronized` blocks (not `ReentrantLock`) for virtual thread compatibility.
294+
- **Virtual thread pinning**: H2 JDBC operations can pin carrier threads. Use `synchronized` blocks (not `ReentrantLock`) for virtual thread compatibility.
295295
- **ANTLR generated sources**: Generated during `mvn generate-sources` from `.g4` files. Do not edit generated code in `grammar/` subdirectories.
296296
- **Graph builder determinism**: Uses indexed result slots (not append order) to ensure virtual thread completion order does not affect output.
297297

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ WORKDIR /app
1212

1313
RUN groupadd -r appuser && useradd -r -g appuser -d /app appuser
1414

15+
RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/*
16+
1517
COPY --from=builder /build/target/code-iq-*.jar app.jar
1618

1719
# Training run for AOT cache — fail loudly so broken images are not published

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
<a href="https://github.com/RandomCodeSpace/code-iq/actions/workflows/ci-java.yml"><img src="https://img.shields.io/github/actions/workflow/status/RandomCodeSpace/code-iq/ci-java.yml?branch=main&style=flat-square&logo=github&label=CI" alt="CI"></a>
1111
<a href="https://www.oracle.com/java/technologies/downloads/"><img src="https://img.shields.io/badge/Java-25-orange?style=flat-square&logo=openjdk&logoColor=white" alt="Java 25"></a>
1212
<a href="https://github.com/RandomCodeSpace/code-iq/blob/main/LICENSE"><img src="https://img.shields.io/github/license/RandomCodeSpace/code-iq?style=flat-square&label=License" alt="MIT License"></a>
13-
<a href="https://sonarcloud.io/summary/overall?id=RandomCodeSpace_code-iq"><img src="https://sonarcloud.io/api/project_badges/measure?project=RandomCodeSpace_code-iq&metric=security_rating" alt="Security"></a>
14-
<a href="https://sonarcloud.io/summary/overall?id=RandomCodeSpace_code-iq"><img src="https://sonarcloud.io/api/project_badges/measure?project=RandomCodeSpace_code-iq&metric=reliability_rating" alt="Reliability"></a>
13+
<a href="https://sonarcloud.io/summary/overall?id=RandomCodeSpace_code-iq-java"><img src="https://sonarcloud.io/api/project_badges/measure?project=RandomCodeSpace_code-iq-java&metric=security_rating" alt="Security"></a>
14+
<a href="https://sonarcloud.io/summary/overall?id=RandomCodeSpace_code-iq-java"><img src="https://sonarcloud.io/api/project_badges/measure?project=RandomCodeSpace_code-iq-java&metric=reliability_rating" alt="Reliability"></a>
1515
<a href="https://github.com/RandomCodeSpace/code-iq"><img src="https://img.shields.io/badge/detectors-97-brightgreen?style=flat-square&logo=codefactor&logoColor=white" alt="97 Detectors"></a>
1616
<a href="https://github.com/RandomCodeSpace/code-iq"><img src="https://img.shields.io/badge/languages-35%2B-blue?style=flat-square&logo=stackblitz&logoColor=white" alt="35+ Languages"></a>
1717
</p>

helm/code-iq/templates/deployment.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,9 @@ spec:
5252
mountPath: /app/data
5353
volumes:
5454
- name: data
55+
{{- if .Values.persistence.enabled }}
56+
persistentVolumeClaim:
57+
claimName: {{ .Release.Name }}-code-iq-data
58+
{{- else }}
5559
emptyDir: {}
60+
{{- end }}

helm/code-iq/templates/pvc.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{{- if .Values.persistence.enabled }}
2+
apiVersion: v1
3+
kind: PersistentVolumeClaim
4+
metadata:
5+
name: {{ .Release.Name }}-code-iq-data
6+
labels:
7+
app: {{ .Release.Name }}-code-iq
8+
spec:
9+
accessModes:
10+
- {{ .Values.persistence.accessMode | default "ReadWriteOnce" }}
11+
resources:
12+
requests:
13+
storage: {{ .Values.persistence.size | default "10Gi" }}
14+
{{- if .Values.persistence.storageClass }}
15+
storageClassName: {{ .Values.persistence.storageClass }}
16+
{{- end }}
17+
{{- end }}

helm/code-iq/values.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ probes:
3737
initialDelaySeconds: 30
3838
periodSeconds: 15
3939

40+
persistence:
41+
enabled: true
42+
size: 10Gi
43+
accessMode: ReadWriteOnce
44+
# storageClass: ""
45+
4046
env:
4147
SPRING_PROFILES_ACTIVE: serving
4248
CODEIQ_GRAPH_PATH: /app/data/graph.db

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@
151151
<scm>
152152
<connection>scm:git:git://github.com/RandomCodeSpace/code-iq.git</connection>
153153
<developerConnection>scm:git:ssh://github.com:RandomCodeSpace/code-iq.git</developerConnection>
154-
<url>https://github.com/RandomCodeSpace/code-iq/tree/java</url>
154+
<url>https://github.com/RandomCodeSpace/code-iq/tree/main</url>
155155
</scm>
156156

157157
<build>

src/main/frontend/package-lock.json

Lines changed: 3 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)