JSON and JSONL

Generate Noir scan results in JSON or JSONL format.

Noir has two JSON output modes:

  • JSON: one JSON object holding all results
  • JSONL: one JSON object per line, good for streaming and large results
Hak, the OWASP Noir mascot

JSON is the format every later stage reads. Pipe it into jq, a script, or an AI auditor's context.

JSON Output

Use -f json to get JSON. Logs go to stderr, so stdout holds only the JSON and is safe to pipe into another tool. Add --no-log to hide the logs as well.

noir scan . -f json --no-log

The result is an object with an endpoints array, a passive_results array, an errors array, and a scan_technologies array. Each endpoint has the URL, HTTP method, and parameters (typed as query, path, header, cookie, form, json, file, xml, and others). It also has the source code location in details.code_paths, the analyzer that produced it in details.technology, and any security tags from taggers.

When more than one analyzer finds the same endpoint, for example a Go router and the project's OpenAPI document, Noir merges them into one entry. details.technology names the analyzer that won the merge, and details.technologies lists every analyzer that contributed, sorted and deduplicated. The list is only emitted when it holds two or more entries, so an endpoint seen by a single analyzer has only technology. A consumer that wants every source should read technologies when present and fall back to [technology] when it is absent.

"details": {
  "code_paths": [
    { "path": "routers/router.go", "line": 42 },
    { "path": "swagger/swagger.json", "line": 1300 }
  ],
  "technology": "go_beego",
  "technologies": ["go_beego", "oas2"]
}

A monorepo can serve the same route from two apps, and Noir keeps those as two endpoints. details.project names the app each one belongs to: the directory of the nearest build manifest (pyproject.toml, package.json, go.mod, pom.xml, ...) above its first source file, relative to the scan base. It is omitted when there is nothing to name: in a scan of a single project (its manifest sits at the base itself), and on endpoints that come from a specification rather than code. Existing reports are therefore unchanged. noir query --project services/orders filters on it.

"details": {
  "code_paths": [{ "path": "mono/services/orders/app.py", "line": 7 }],
  "technology": "python_flask",
  "project": "services/orders"
}

Some of what Noir reports is read off a definition, and some is a best guess. resolution lists the claims of an endpoint that were not read in full, each with one of two values:

  • heuristic: matched by name, shape or proximity
  • unresolved: the reference was seen, but Noir could not follow it

A claim read in full is not listed, and an endpoint with nothing to list has no resolution key. This version marks three claims, and only some analyzers and auth taggers set them, so a missing key means nothing was marked, not that every claim on the endpoint was verified.

Go marks prefix, handler and guard. prefix: unresolved means the route's path has a leading operand Noir did not read, and the URL is the literal part after it. oapi-codegen registers every operation as r.Get(options.BaseURL+"/status", ...), which is reported as /status. The real path may have something in front of it. A group or mount prefix Noir did read is still joined on (r.Mount("/api", ...) gives /api/status), and the mark stays, because the operand between them is still unread. The same mark goes on every route registered on a group whose prefix Noir did not read in full, and on groups nested under it, in whatever file or package the routes are: apache/answer's r.Group(uiConf.APIBaseURL + "/answer/api/v1") keeps the /answer/api/v1 tail, and woodpecker's e.Group(server.Config.Server.RootPath) adds nothing to its routes' paths. A group written inline is read the same way: r.Group(base + "/v1").GET("/x", h) is reported as /v1/x, and register(r.Group(base + "/v2")) adds /v2 to the helper's routes; both are marked. So does a router-builder helper with a group parameter (func register(g *echo.Group), *gin.RouterGroup) that no call site hands a readable group; one whose parameter is an interface that may be the root router (fiber.Router, gin.IRouter) is not marked. A group whose prefix was read in full leaves its routes unmarked. When two rows for the same method and path merge, a claim either row marks stays marked. noir query --resolution unresolved lists these rows.

Express also marks prefix: unresolved on JavaScript/TypeScript router mounts whose prefix could not be read in full: app.use(config.basePath + '/v1', router) keeps /v1, while app.use(process.env.API_PREFIX, router) adds no path. The mark carries through nested mounts and routers resolved from other files. A partly read prefix or a template placeholder keeps its path and gets the mark; a literal prefix or a constant read in full does not.

The FastAPI analyzer marks unread prefixes on APIRouter(prefix=...) and include_router(..., prefix=...), keeping a final slash-rooted literal tail such as BASE + "/v1".

{
  "url": "/api/status",
  "method": "GET",
  "resolution": { "prefix": "unresolved" },
  "details": {
    "code_paths": [{ "path": "api/api.gen.go", "line": 32 }],
    "technology": "go_chi"
  }
}

handler: heuristic means Noir picked the handler definition by name, wrapper shape or proximity without establishing the reference's link to that definition. The handler's name, path and line still show the picked definition; noir query --resolution heuristic lists these rows. A handler reference that produced no definition is not marked.

guard: heuristic means Go auth/authz tags say the endpoint is guarded, but every path to that conclusion used a name, shape or text-level scope match. Group and router-level middleware also counts as followed when the syntax tree shows it applies to the route and its body was followed to a refusal. A guarded Go endpoint without this mark has at least one followed guard, not necessarily every guard; an endpoint with no guard tag is left unmarked. This is a mark on the endpoint's guarded status, not on each entry in ai_context.guards.

spring_auth applies the same claim to Java and Kotlin Spring endpoints. A standard restrictive annotation on the handler or class, read in full, stays unmarked. URL-rule matches, opaque or composed annotations, interceptor/filter scopes, unread configurations and shape-matched handler refusals get guard: heuristic, because what they mean or which routes they cover is inferred.

Express auth tags also use guard: heuristic when every guard relies on a name, shape or text-level scope inference. A guarded Express endpoint without this mark has at least one followed refusal, and an endpoint without guard tags gets no guard mark.

The YAML, JSONL and TOML outputs carry the same field, and the plain report prints it as a resolution row.

An auth tag can carry requires, the access the guard asks of a caller. It is a list of clauses, and every clause must hold. A clause holds when any one of its any_of atoms does. Each atom has a kind, which is one of role, permission, scope, authenticated, anonymous, deny or unresolved, and most kinds also have a value. An unresolved atom keeps the source text Noir could not read, such as a bean call, a negation, or a constant from another file. Treat it as a condition no caller is known to meet. Each clause also names its source declaration and, when known, its path and line. An empty list means the guard admits every caller. A tag without the key comes from a tagger that does not read requirements yet. The access matrix page lists the sources that set it. Other tags can carry it too: a denied tag, an anonymous tag, and a declaration tag such as azure-auth-level.

spring_auth reads the handler's annotations. A handler annotation replaces the class's annotation of the same kind. An annotation of another kind declared farther away (a class @PreAuthorize over a handler @RolesAllowed) is kept as an unresolved clause, because Spring Security 5 and 6 treat it differently. A condition only signed-out callers pass (isAnonymous()) is unresolved too. It then adds the clauses of the security filter chain rule that matches the route, because the chain and the annotations must all pass. An interceptor or servlet filter that matches a guarded route adds an unresolved clause.

A route denied outright (@DenyAll, @PreAuthorize("denyAll()"), a chain denyAll()) is not an authentication guard, so it gets a denied tag in place of an auth tag. That tag's requires holds one clause with the deny atom.

{
  "name": "auth",
  "description": "Protected by Spring @PreAuthorize",
  "tagger": "spring_auth",
  "requires": [
    {
      "any_of": [{ "kind": "role", "value": "ADMIN" }, { "kind": "permission", "value": "posts:write" }],
      "source": "@PreAuthorize(\"hasRole('ADMIN') or hasAuthority('posts:write')\")",
      "path": "src/main/java/com/example/PostController.java",
      "line": 31
    },
    {
      "any_of": [{ "kind": "authenticated" }],
      "source": "authenticated()",
      "path": "src/main/java/com/example/SecurityConfig.java",
      "line": 19
    }
  ]
}

The YAML, JSONL and TOML outputs carry requires as well.

A full report looks like this. It was produced with taggers enabled (-T), which is what fills the tags arrays.

{
  "endpoints": [
    {
      "callees": [],
      "url": "/query",
      "method": "POST",
      "internal": false,
      "details": {
        "code_paths": [
          {
            "path": "spec/functional_test/fixtures/crystal/kemal/src/testapp.cr",
            "line": 17
          }
        ],
        "technology": "crystal_kemal"
      },
      "protocol": "http",
      "kind": "",
      "tags": [],
      "params": [
        {
          "name": "my_auth",
          "value": "",
          "param_type": "cookie",
          "tags": []
        },
        {
          "name": "query",
          "value": "",
          "param_type": "form",
          "tags": []
        }
      ]
    },
    {
      "callees": [],
      "url": "/token",
      "method": "GET",
      "internal": false,
      "details": {
        "code_paths": [
          {
            "path": "spec/functional_test/fixtures/crystal/kemal/src/testapp.cr",
            "line": 22
          }
        ],
        "technology": "crystal_kemal"
      },
      "protocol": "http",
      "kind": "",
      "tags": [
        {
          "name": "oauth",
          "description": "Suspected OAuth endpoint for granting 3rd party access.",
          "tagger": "Oauth"
        }
      ],
      "params": [
        {
          "name": "client_id",
          "value": "",
          "param_type": "form",
          "tags": []
        },
        {
          "name": "redirect_url",
          "value": "",
          "param_type": "form",
          "tags": [
            {
              "name": "ssrf",
              "description": "This parameter may be vulnerable to Server Side Request Forgery (SSRF) attacks.",
              "tagger": "Hunt"
            }
          ]
        },
        {
          "name": "grant_type",
          "value": "",
          "param_type": "form",
          "tags": []
        }
      ]
    }
  ],
  "passive_results": [],
  "errors": [],
  "scan_technologies": ["crystal_kemal"]
}

Detected technologies

scan_technologies lists the technologies the scan ran with, sorted. It holds the ones detection found, including a framework whose analyzer produced no endpoint, and the ones passed with --techs.

{
  "scan_technologies": ["crystal_kemal", "oas3"]
}

An endpoint's details.technology names the analyzer that produced it. scan_technologies answers a different question: whether a framework was detected at all. A framework that is listed here and has no endpoints was detected and found nothing; one that is missing was never detected.

OpenAPI comparison coverage

A single noir scan -f json records coverage.openapi even when the scan produces zero endpoints. For example:

{"enabled_analyzers":["oas2","oas3"],"documents_read":1,"status":"available"}

enabled_analyzers lists the OpenAPI versions allowed by this scan's technology selection. documents_read counts distinct root documents whose paths map Noir read. An empty map counts as one document. Reading external $ref fragments adds no documents.

Status What the scan established
available At least one root paths map was read with no reported OpenAPI or file-discovery gaps.
no_documents OpenAPI was enabled and zero root paths maps were read, with no reported gaps.
disabled The scan settings excluded both OpenAPI analyzers.
incomplete File discovery or an enabled OpenAPI analyzer reported a gap. Other documents may have been read successfully. See errors.

For a PR summary, scan the service and its relevant contracts together. This example lists HTTP routes found in code but absent from the OpenAPI documents read in that scope. If the comparison was unavailable it prints the reason. Older reports give unknown.

jq '
  .coverage.openapi.status as $status
  | if $status == "available" then
      [.endpoints[]
       | select(.protocol == "http" and .internal != true)
       | select(any(.details.origins[]?; .kind == "code"))
       | select(any(.details.origins[]?; .technology == "oas2" or .technology == "oas3") | not)
       | {method, url}]
    else {openapi_comparison: ($status // "unknown")} end
' report.json

Analyzer Failures

If an analyzer crashes, Noir logs it, skips it, and continues with the other analyzers. A single file an analyzer cannot read or parse (a file over the parse-time limit, for instance) is skipped the same way, and only that file is lost. errors records both. That lets you tell a framework with no endpoints from one that was never analyzed, and a complete scan from one that quietly dropped files:

{
  "endpoints": [],
  "passive_results": [],
  "errors": [
    { "tech": "go_gin", "message": "Index out of bounds" },
    { "tech": "rust_axum", "message": "skipped 2 files: src/gen.rs, src/vendor.rs; first error: ts_parser_parse_string returned null (timed out after 10000ms, or out of memory)" }
  ]
}

Skipped files are tallied per tech rather than listed one entry each, with up to five example paths, so a broken checkout cannot flood the report.

The key is always present. "errors": [] means every selected analyzer ran to completion over every file it was given.

-f yaml carries the same key, and -f sarif reports it as runs[0].invocations[0].executionSuccessful. Add --strict to make a degraded scan exit with code 2, after the report has been written:

noir scan . -f json --no-log --strict > endpoints.json

JSONL Output

JSON Lines prints one JSON object per line. Use it with jq, or to process a large result line by line without loading it all into memory.

noir scan . -f jsonl --no-log

Each line is a self-contained endpoint object. With -P, passive scan findings follow the endpoints, one per line (tell them apart by shape: endpoints have url and method, findings have id and info). If an analyzer failed, each failure comes last as its own line with tech and message (the same entries errors holds in JSON). A clean scan writes no such line. Use --strict to turn a degraded scan into a non-zero exit code.

{"callees":[],"url":"/","method":"GET","internal":false,"details":{"code_paths":[{"path":"./src/testapp.cr","line":3}],"technology":"crystal_kemal"},"protocol":"http","kind":"","tags":[],"params":[{"name":"x-api-key","value":"","param_type":"header","tags":[]}]}
{"callees":[],"url":"/query","method":"POST","internal":false,"details":{"code_paths":[{"path":"./src/testapp.cr","line":17}],"technology":"crystal_kemal"},"protocol":"http","kind":"","tags":[],"params":[{"name":"my_auth","value":"","param_type":"cookie","tags":[]},{"name":"query","value":"","param_type":"form","tags":[]}]}