Skip to content

Commit fb8f751

Browse files
committed
docs: add L3/L4 dataflow, taint, and the IaC backend
Three new pages, written in the same Simplified Technical English as the rest of the site, with 2.0 features badged as a release candidate: - guides/dataflow.mdx the four analysis levels, CFG/CDG/DDG per callable, value addressing (resolve_callable/resolve_value/locate), slicing (slice_forward/slice_backward/backward_cone), reachability and flow paths, and the ssa > reaching-defs > points-to provenance ranking - guides/taint.mdx taint(sources, sinks, sanitizers), the two sanitizer shapes, and what TaintResult.exhausted does and does not claim - backends/codeanalyzer-iac.mdx caniac: Helm SDK 4.2.4, levels 1-3, emit modes, graph mode, exit status, schema pin Updated to match: - concepts + what-is-cldk: two analysis levels -> four - backends overview: IaC row and card - cheatsheet: dataflow and taint method table - installing: IaC tab and a `pip install --pre cldk` note - sidebar: three new entries Every documented signature, field name, and default was read out of python-sdk v2.0.0-rc.7 and the codeanalyzer-iac README rather than inferred. Levels 3 and 4, and every method on the two new guide pages, are 2.0 only; PyPI stable is 1.5.0, so each page says so. Note: caniac takes -a 1|2|3 and rejects 4, which is a different scale from the language backends' -a 1..4. Both new pages call that out. There is no CLDK.iac(...) factory yet; the IaC page says so.
1 parent fe316d5 commit fb8f751

9 files changed

Lines changed: 561 additions & 6 deletions

File tree

‎astro.config.mjs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ export default defineConfig({
154154
items: [
155155
{ label: "Core concepts", slug: "guides/concepts", attrs: { "data-cldk-icon": "learning-16" } },
156156
{ label: "Common tasks", slug: "guides/common-tasks", attrs: { "data-cldk-icon": "workflow-16" } },
157+
{ label: "Dataflow graphs", slug: "guides/dataflow", attrs: { "data-cldk-icon": "diagram-tree-16" } },
158+
{ label: "Taint analysis", slug: "guides/taint", attrs: { "data-cldk-icon": "detection-16" } },
157159
{
158160
label: "Code Context Agent",
159161
slug: "cocoa",
@@ -204,6 +206,7 @@ export default defineConfig({
204206
{ label: "codeanalyzer-python", slug: "backends/codeanalyzer-python", attrs: { "data-cldk-icon": "python" } },
205207
{ label: "codeanalyzer-java", slug: "backends/codeanalyzer-java", attrs: { "data-cldk-icon": "java" } },
206208
{ label: "codeanalyzer-ts", slug: "backends/codeanalyzer-ts", attrs: { "data-cldk-icon": "typescript" } },
209+
{ label: "codeanalyzer-iac", slug: "backends/codeanalyzer-iac", attrs: { "data-cldk-icon": "cloud-16" } },
207210
],
208211
},
209212
{

‎src/content/docs/backends.mdx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: "CLDK is a Python frontend over standalone per-language backends, t
55

66
import { Badge, CardGrid, LinkCard, Aside } from "@astrojs/starlight/components";
77

8-
**Standalone language backends** parse the source, resolve the symbols, and build the call graph. There is one backend for each language. Together they are the `codeanalyzer-*` tools. Each backend writes typed JSON. The SDK reads that JSON and builds models that you can query.
8+
**Standalone language backends** parse the source, resolve the symbols, and build the call graph. There is one backend for each language, and one more for infrastructure-as-code. Together they are the `codeanalyzer-*` tools. Each backend writes typed JSON. The SDK reads that JSON and builds models that you can query.
99

1010
```mermaid
1111
flowchart LR
@@ -43,6 +43,7 @@ The `codeanalyzer-*` tools parse a language. Then they write the canonical symbo
4343
| **Python** | [codeanalyzer-python](/backends/codeanalyzer-python/) | <Badge text="Mature" variant="success" /> |
4444
| **TypeScript** | [codeanalyzer-ts](/backends/codeanalyzer-ts/) | <Badge text="Beta" variant="caution" /> |
4545
| **JavaScript** | via [codeanalyzer-ts](/backends/codeanalyzer-ts/) | <Badge text="Medium" variant="tip" /> |
46+
| **IaC (Helm)** | [codeanalyzer-iac](/backends/codeanalyzer-iac/) | <Badge text="Beta" variant="caution" /> |
4647
| **Go** | Not started | <Badge text="Help wanted" variant="danger" /> <Badge text="Stub" variant="default" /> |
4748
| **Rust** | Not started | <Badge text="Help wanted" variant="danger" /> <Badge text="Stub" variant="default" /> |
4849
| **C** | Not started | <Badge text="Help wanted" variant="danger" /> <Badge text="Stub" variant="default" /> |
@@ -55,5 +56,6 @@ The `codeanalyzer-*` tools parse a language. Then they write the canonical symbo
5556
<LinkCard title="codeanalyzer-python" description="Jedi-based semantic analysis with optional CodeQL call-graph augmentation. Writes the canonical Py* schema." href="/backends/codeanalyzer-python/" />
5657
<LinkCard title="codeanalyzer-java" description="WALA and Javaparser. Produces symbol tables, call graphs, type hierarchy, and CRUD analysis." href="/backends/codeanalyzer-java/" />
5758
<LinkCard title="codeanalyzer-ts" description="Beta. The TypeScript and TSX backend. It writes the canonical symbol-table and call-graph schema. Entrypoint detection is not complete." href="/backends/codeanalyzer-ts/" />
59+
<LinkCard title="codeanalyzer-iac" description="Beta. The infrastructure-as-code backend. It turns Helm charts into the canonical schema v2 IaC model, as JSON or a Neo4j graph." href="/backends/codeanalyzer-iac/" />
5860
<LinkCard title="Add a backend" description="Help wanted. Go, Rust, C, C++, and C# do not exist yet. A backend that writes the canonical JSON makes that language available to every SDK." href="/contributing/add-language-backend/" />
5961
</CardGrid>
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
---
2+
title: codeanalyzer-iac
3+
description: "The infrastructure-as-code backend. It turns Helm charts into the canonical schema v2 IaC model, as analysis.json or a Neo4j property graph."
4+
---
5+
6+
import { Tabs, TabItem, Aside, Badge, LinkCard, CardGrid, Steps } from "@astrojs/starlight/components";
7+
8+
<p><Badge text="Beta" variant="caution" /></p>
9+
10+
The **codeanalyzer-iac** backend analyzes infrastructure-as-code. Its command is **`caniac`**. It reads a repository, or a Neo4j graph that already holds one, and publishes one typed model of the infrastructure sources.
11+
12+
`caniac` is built on the [Helm](https://helm.sh/) SDK, pinned to version 4.2.4. It never calls the `helm` CLI. Helm is the first dialect. Every other file stays an ordinary `Artifact`, and the analyzer never drops it.
13+
14+
<Aside type="caution" title="There is no CLDK.iac(...) factory yet">
15+
The other backends have a matching SDK facade. This one does not. Use `caniac` as a command, or read the graph that it writes. Java, Python, and TypeScript analyses are unaffected.
16+
</Aside>
17+
18+
## Install
19+
20+
<Tabs>
21+
<TabItem label="Shell">
22+
Prebuilt binary for macOS and Linux:
23+
24+
```bash
25+
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/codellm-devkit/codeanalyzer-iac/releases/latest/download/caniac-installer.sh | sh
26+
```
27+
</TabItem>
28+
<TabItem label="Homebrew">
29+
```bash
30+
brew install codellm-devkit/tap/codeanalyzer-iac
31+
```
32+
</TabItem>
33+
<TabItem label="pip">
34+
```bash
35+
pip install codeanalyzer-iac
36+
```
37+
</TabItem>
38+
</Tabs>
39+
40+
## Analyze a repository
41+
42+
```bash
43+
caniac --app-name payments .
44+
caniac --app-name payments charts/ deploy/values-prod.yaml
45+
caniac --app-name payments --workspace-root . charts/api
46+
```
47+
48+
Paths can be files or directories, and they can overlap. They are selection filters, not identity roots. Identity comes from `--workspace-root`, which defaults to the current directory. `charts/api/values.yaml` is therefore the same artifact whether you selected the repository, `charts/`, or that one file.
49+
50+
Every input file and every `--config` file must resolve below the workspace root. The analyzer does not follow symlinks out of it, and the walker skips `.git`.
51+
52+
With no path, the input is `.`. With no `--app-name`, the application takes the base name of the workspace root. In graph mode a name is mandatory.
53+
54+
## Analysis levels
55+
56+
<Aside type="caution" title="This scale is not the SDK scale">
57+
`caniac` takes `-a 1|2|3`. The language backends take `-a 1..4`. The numbers do not line up, and level 4 here is rejected rather than accepted. Read this table, not the [dataflow levels](/guides/dataflow/#the-four-analysis-levels).
58+
</Aside>
59+
60+
| Level | Adds | Never does |
61+
| --- | --- | --- |
62+
| L1 | Artifact classification, Helm facets, chart metadata, values keys, template definitions, template calls, value references, resource templates, source diagnostics | Resolution or rendering |
63+
| L2 | Chart membership, dependency resolution, named-template targets, value-reference targets, unresolved records | Rendering or any I/O |
64+
| L3 | Render profiles, value layers, renders, rendered Kubernetes resources and addresses | Cluster access, install, upgrade, dependency fetching |
65+
66+
`-a/--analysis-level` takes 1, 2, or 3, and defaults to 1. The levels are additive. Every fact that a lower level published is present, unchanged, at every higher level.
67+
68+
The graph always receives the deepest implemented level, which is L3 today. `--emit cypher` and `--emit neo4j` therefore raise the level to 3 unless you passed `--analysis-level` yourself. An explicit level below 3 with those targets is rejected rather than raised without a word.
69+
70+
```bash
71+
caniac testdata/helm/l1-v2 --app-name payments --analysis-level 1 > analysis.json
72+
73+
caniac --workspace-root testdata/helm/profiles --app-name payments \
74+
--config .codeanalyzer-iac.yaml --analysis-level 3 > analysis.json
75+
```
76+
77+
## Output modes
78+
79+
| `--emit` | Writes | To stdout | To `-o DIR` |
80+
| --- | --- | --- | --- |
81+
| `json` (filesystem default) | The analysis document | Compact JSON, one trailing newline | `analysis.json` |
82+
| `cypher` | The replayable projection script | The script | `graph.cypher` |
83+
| `neo4j` (graph-mode default) | A reconciled generation over Bolt | Nothing | Nothing |
84+
| `schema` | The embedded graph catalog | `schema.neo4j.json` | `schema.neo4j.json` |
85+
86+
In filesystem mode, `--emit cypher` never consults the target graph. The script is projected from the analysis alone, so it has no hash-conflict guard against facts that are already in the graph. `--emit neo4j` does have that guard.
87+
88+
`--emit schema` takes no input path. `-f/--format` accepts only `json`. `msgpack` is named so that the analyzer can reject it with a clear message instead of a bad parse. `-j/--jobs` bounds parallel parsing and rendering, and it defaults to the CPU count. The output is byte-identical whatever you set it to.
89+
90+
Stdout carries analysis data and nothing else. Errors go to stderr, one line each. A successful run leaves stderr empty. The analyzer discards the value-coalescing warnings that Helm itself emits, rather than letting them onto either stream.
91+
92+
## Graph mode
93+
94+
A single positional Neo4j or Bolt URI switches the analyzer into graph mode.
95+
96+
```bash
97+
caniac neo4j://localhost:7687 --app-name payments
98+
```
99+
100+
In graph mode the analyzer reads the complete `Artifact.source` for every `can://artifact/<app-name>/...` node, makes sure that each one matches the stored `sha256`, and writes its enrichment back onto those same nodes.
101+
102+
`--app-name` is required here. The URI names a database, not an application, and the analyzer will not pick one for you. You cannot mix a URI and filesystem paths in one invocation. In graph mode `--emit` defaults to `neo4j`, so the command above reads and writes the same database over one connection.
103+
104+
If a source does not match its recorded hash, that becomes a diagnostic on the artifact and the analyzer skips its semantic model. The recorded spans address the old text, so a changed source makes every one of them wrong. Other artifacts are analyzed normally. There is no flag to accept a mismatch.
105+
106+
## Exit status
107+
108+
| Exit | Meaning |
109+
| --- | --- |
110+
| 0 | The analysis completed |
111+
| 1 | An analyzer-wide failure, or `--strict` with at least one error-severity diagnostic |
112+
113+
Isolated failures are diagnostics inside the model, not process failures. An unparsable file, or a chart that the analyzer cannot render, still exits 0. A file that the analyzer cannot read as text stays a raw inventory entry, with a digest and no source, and reports `IAC_SOURCE_NOT_TEXT` at `warning` severity. A repository with binaries in it therefore still passes `--strict`.
114+
115+
Whether a document is published on exit 1 depends on how far the run got:
116+
117+
- An invalid configuration and a `--strict` failure are both decided after the analysis is written, so those runs still leave a document to read.
118+
- An unreadable input root, an unreachable graph, and a failed graph commit all end the run before that write, so they publish nothing.
119+
120+
`--strict` changes only the exit status. It never changes the document.
121+
122+
`--eager` reconciles away the stale facts that this analyzer owns for the selected application: `codeanalyzer-iac` nodes and aliases, `iac_*` properties, facet labels, and `IAC_*` relationships. It never removes an `Artifact`.
123+
124+
## Schema
125+
126+
The repository pins the accepted `codeanalyzer-schema` contract at commit [`b84428f`](https://github.com/codellm-devkit/codeanalyzer-schema/commit/b84428f1accebe2b259d32c15387f04a00167f2c). `make schema-check` and the pin-parity test keep every copy of that commit in step.
127+
128+
## See also
129+
130+
<CardGrid>
131+
<LinkCard title="Backends overview" href="/backends/" description="All CLDK analysis backends and their maturity tiers." />
132+
<LinkCard title="Analysis at scale" href="/at-scale/" description="The emit and poll split that this backend writes into." />
133+
<LinkCard title="Deploy on Kubernetes" href="/at-scale/kubernetes/" description="Scheduled emit jobs against a shared Neo4j." />
134+
<LinkCard title="Source repository" href="https://github.com/codellm-devkit/codeanalyzer-iac" description="codellm-devkit/codeanalyzer-iac on GitHub." />
135+
</CardGrid>

‎src/content/docs/guides/concepts.mdx‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Core concepts
33
description: Symbol tables, call graphs, and the analysis levels that produce them.
44
---
55

6-
import { Tabs, TabItem, Steps, Aside, LinkCard, CardGrid } from "@astrojs/starlight/components";
6+
import { Tabs, TabItem, Steps, Aside, Badge, LinkCard, CardGrid } from "@astrojs/starlight/components";
77

88
CLDK analyzes a project and gives you structured program facts through one `analysis` object. The call graph answers questions about structure, such as which methods call a given method. You do not read the source files yourself.
99

@@ -126,10 +126,14 @@ CLDK gives you the graph as a `networkx.DiGraph` (edges point from caller to cal
126126

127127
## Analysis levels
128128

129-
The **analysis level** controls how much work CLDK does when it builds the `analysis` object. There are two:
129+
The **analysis level** controls how much work CLDK does when it builds the `analysis` object. There are four. Each level is a superset of the level below it.
130130

131131
- `AnalysisLevel.symbol_table`: the **default**. Resolves structure (classes, methods, fields, signatures). Fast, and enough for symbol-table queries.
132132
- `AnalysisLevel.call_graph`: also computes call edges. **Required** for `get_call_graph`, `get_callers`, and `get_callees`.
133+
- `AnalysisLevel.program_dependency_graph`: also builds dataflow inside each callable. <Badge text="2.0" variant="caution" />
134+
- `AnalysisLevel.system_dependency_graph`: also builds dataflow across call boundaries. <Badge text="2.0" variant="caution" />
135+
136+
Levels 1 and 2 are the two levels that CLDK 1.x has. Levels 3 and 4 arrive in CLDK 2.0, which is a release candidate today. See [Dataflow graphs](/guides/dataflow/) for what they build and [Taint analysis](/guides/taint/) for the queries over them.
133137

134138
```python
135139
from cldk import CLDK
@@ -155,6 +159,7 @@ Java has a single-file mode, `CLDK.java(source_code="...")`, for quick syntactic
155159

156160
<CardGrid>
157161
<LinkCard title="Common tasks" description="Copy-paste snippets for each of these queries on a real project." href="/guides/common-tasks/" />
162+
<LinkCard title="Dataflow graphs" description="Levels 3 and 4: control flow, data dependence, slicing, and flow paths." href="/guides/dataflow/" />
158163
<LinkCard title="COCOA" description="Build a Code Context Agent plugin over symbol tables and call graphs." href="/cocoa/" />
159164
<LinkCard title="Java API reference" description="Every method on the most complete analysis API." href="/reference/python-api/java/" />
160165
</CardGrid>

0 commit comments

Comments
 (0)