Skip to content
Skip to content
Documentation

GuardDog scanner (community plugin)

Pending licensing review. The GuardDog plugin, and GuardDog and the libraries it bundles that the ASH container image ships for it, are pending licensing review.

GuardDog (Apache-2.0, by Datadog) looks for the shapes malicious packages take: an install hook that downloads and runs a script, exec of a base64-decoded payload, obfuscated JavaScript, exfiltration to a raw IP address, and similar. Its YARA rules ship inside the GuardDog package, so scanning local source needs no network.

Enabling it

GuardDog is a community plugin that ships with ASH. Its plugin module is loaded only when you list it, so an ash scan that does not list it is unchanged: no row in the results, the summary, the reports or the SARIF.

# .ash/.ash.yaml
ash_plugin_modules:
  - automated_security_helper.plugin_modules.ash_guarddog_plugins
# For one run
ash scan --ash-plugin-modules automated_security_helper.plugin_modules.ash_guarddog_plugins

With the module listed, guarddog runs by default, like every other scanner. scanners.guarddog.enabled: false turns it off again, and --scanners and --exclude-scanners select it as they select any scanner. --scanners guarddog without the module listed is refused, with a message naming the module to add. If GuardDog is not installed, an online scan installs it with uv tool install before running it; offline, in nix mode, or when that install fails, the scanner is reported MISSING and the scan exits 1 (the incomplete-scan gate).

What ASH runs

For every enabled ecosystem, ASH finds each package root in the scanned directory, a directory holding one of that ecosystem's manifests, and runs guarddog <ecosystem> scan <package root> --output-format json on it:

Ecosystem Package root manifest
pypi setup.py, setup.cfg, pyproject.toml
npm package.json
go go.mod
github_action action.yml, action.yaml
rubygems *.gemspec
crates Cargo.toml

GuardDog reads every file under the directory it is given and has no exclusion option, so ASH does not hand it the package root itself. It builds a temporary copy (files are copied, never hard-linked) holding only the files ASH would scan: the scan set after .gitignore and .ignore, without node_modules/, .venv/ and venv/ directories, global_settings.ignore_paths, options.excluded_paths, ASH's output directory, and any nested package root of the same ecosystem, which is scanned on its own. Symlinks are never copied, so GuardDog cannot read anything outside the scanned directory through one.

A file under two package roots of different ecosystems (a .js file in a Python package that also contains a package.json) is matched by both scans; ASH reports each finding once.

Dependency verification (verify, off by default)

With options.verify: true, ASH also runs guarddog <ecosystem> verify <manifest> on each dependency manifest: requirements.txt and requirements-dev.txt (pypi), package.json (npm), go.mod (go), Gemfile.lock (rubygems), Cargo.lock (crates) and workflow files under .github/workflows/ (github_action). GuardDog downloads every dependency the manifest names from its registry and scans it.

This needs network access and can take a long time on a large manifest. Each manifest is bounded by options.verify_timeout (600 seconds by default). A finding in a dependency is reported on the manifest line that names the dependency, and carries package_name and package_version, so package-scoped suppressions apply to it.

Severity mapping

GuardDog correlates its matches into risks: a threat pattern, optionally paired with a capability that makes it actionable, with a severity taken from the threat rule and lowered one band when the capability is in another file and two bands when it is in another category. ASH uses that judgment directly.

GuardDog output ASH severity SARIF level
Risk with severity high HIGH error
Risk with severity medium MEDIUM warning
Risk with severity low LOW note
Risk with any other severity value MEDIUM warning
threat-* match that GuardDog did not correlate into a risk LOW note
Metadata rule that fired (typosquatting, compromised email domain) MEDIUM warning
Every capability-* match, with include_capabilities INFO none

Capability matches ("spawns a process", "reads a file") describe ordinary code as often as malicious code, so they are only reported when options.include_capabilities is true. Then every one is reported, including a match a risk also used: GuardDog's JSON names the capability rule a risk used, not which of its matches.

Why not GuardDog's own SARIF: GuardDog 3.2.0 offers SARIF only for verify, not for scan, and gives every rule the level warning, which carries no severity. ASH reads GuardDog's JSON in both modes and converts it.

Suppressions

Every GuardDog finding has a rule id (the GuardDog rule name, for example threat-runtime-obfuscation-base64exec), a file and a line in your repository, so these apply:

  • rule, path and line suppressions, as for any scanner;
  • symbol-scoped suppressions (a function or class), for findings in source files ASH can parse;
  • package-scoped suppressions (package_name, package_version) for verify findings, which are findings in a dependency.

To stop GuardDog evaluating a rule at all, use options.exclude_rules, or options.rules to run only some rules. The two cannot be combined. Each ecosystem has its own rule set (guarddog <ecosystem> list-rules), so ASH passes each ecosystem only the configured names it knows: an exclusion it does not know is ignored for it, and an ecosystem that knows none of the rules names is not scanned. A name no scanned ecosystem knows is reported as an error, since it is most likely a typo.

How many matches GuardDog reports

GuardDog stops evaluating a source-code rule once it has that rule's number of hits in the package root it was given (the max_hits field of the rule's YARA metadata: 1, 3 or 5 in GuardDog 3.2.0), and forms at most that many risks from the rule in one file. Files are walked in sorted order, so the matches reported are the first ones. For a dependency under verify the count is per dependency.

options.max_hits sets that number for every rule; 0 removes the limit, so every match is reported. Unset, the default, keeps each rule's own limit.

scanners:
  guarddog:
    options:
      max_hits: 0   # report every match

GuardDog has no flag or environment variable for this, so with max_hits set ASH does not run the guarddog executable. It runs GuardDog's own command-line entry point in GuardDog's Python interpreter (uv tool run --from guarddog==3.2.0 python, or the interpreter of the guarddog on PATH), after setting the limit on each of the rules GuardDog loaded; GuardDog's arguments and output are unchanged. With a GuardDog release that does not keep a per-rule max_hits where 3.2.0 does, each invocation is a failed target and the scanner reports ERROR, rather than running with GuardDog's own limits.

A lower limit hides matches, so a value below a rule's own limit applies to it only when you set it on the command line (--config-overrides) or in a config file outside the scanned tree. Set in a config inside the scanned tree, or by an MCP client, max_hits only raises limits: a rule whose own limit is higher keeps it, and the scan logs a warning saying so. 0 only raises, so it applies from any config.

Offline and air-gapped use

guarddog scan runs offline. ASH does not install tools in offline mode, so GuardDog has to be installed beforehand; the ASH container image includes it. With GuardDog absent offline, the scanner is reported MISSING, with the install command in the log.

verify downloads packages, so under ASH_OFFLINE ASH does not attempt it: each manifest it would have read is a failed target and the scanner reports ERROR, naming the reason. Set options.verify: false for offline scans. Online, a verify run in which GuardDog logged an error is also a failed target: when the registry cannot be reached, GuardDog prints an empty result and exits 0, which would otherwise read as a clean scan.

GuardDog is not packaged in nixpkgs, so ash scan --mode nix does not provide it. Enabled under Nix without a separately installed GuardDog, the scanner is MISSING.

Failures

Every GuardDog invocation that times out, exits non-zero, prints no result or prints something other than a result, or reports a rule error, is a package or manifest GuardDog did not check. The scanner then reports ERROR (and the scan exits 1) however many other invocations succeeded. The findings that were produced are kept in <output dir>/scanners/guarddog/<source|converted>/guarddog.sarif, and each invocation's stdout and stderr are under .../invocations/.

Kernel sandbox

GuardDog 3.x can run its scan inside a kernel sandbox (nono: Landlock on Linux, Seatbelt on macOS) that blocks network access and limits reads to the scanned directory. options.sandbox controls it:

  • auto (default): use it where the platform supports it, otherwise scan without it and log a warning once per scan. It is available in the ASH image under Docker; some container runtimes, seccomp profiles and older kernels do not allow it.
  • required: report ERROR where it is unavailable.
  • disabled: never use it.

The sandbox applies to scan only; GuardDog does not offer it for verify. Under ASH's own --sandbox, verify gets no network access, so it cannot download dependencies.

On macOS, ASH's --sandbox runs the scan under sandbox-exec, and macOS does not allow a second sandbox inside it: GuardDog's own would fail with Sandbox initialization failed: Operation not permitted and scan nothing. With auto, ASH therefore runs guarddog scan --no-sandbox there, and ASH's sandbox is the one that confines it (no network, and reads and writes limited to the paths ASH grants). required still asks for GuardDog's sandbox and reports ERROR there; disabled is unchanged.

Installation

ASH installs GuardDog with uv tool install, pinned to the release its result parser was tested against (guarddog==3.2.0) and to a Python interpreter between 3.10 and 3.13: pygit2 and yara-python, two of GuardDog's dependencies, publish no CPython 3.14 wheels at that version, so an install on 3.14 would have to compile them from source. ash dependencies install (with the module listed in ash_plugin_modules) and the container image do this for you, and an online scan that finds no GuardDog installs it the same way before running it, within options.install_timeout. To install it yourself:

uv tool install --python '>=3.10,<3.14' 'guarddog==3.2.0'

In the container image, GuardDog's pygit2 is pinned to the release whose license files the image ships under /usr/share/doc/ash/third-party/. The pin is a uv constraint file, /etc/ash/uv-constraints.txt (pygit2==1.18.2), set image-wide with UV_CONSTRAINT, so it also applies to any uv command you run in the container. It changes nothing for an install that does not pull pygit2 in; unset UV_CONSTRAINT to drop it.

GuardDog 3.2.0 cannot be installed on Windows: its dependency nono-py publishes no Windows build and does not compile there. On Windows, ash dependencies install does not try, and an enabled GuardDog is reported SKIPPED with that reason.

options.tool_version overrides the version constraint. It must be a PEP 440 version specifier such as ==3.2.0; any other value is ignored with a warning and the default is used. A GuardDog release other than 3.2.0 may print JSON the parser does not expect; if it does, the invocation is a failed target rather than a silently empty result.

Configuration

scanners:
  guarddog:
    enabled: true               # once the module is listed; false turns it off
    options:
      ecosystems: [pypi, npm, go, github_action, rubygems, crates]
      verify: false             # downloads dependencies; refused offline
      verify_timeout: 600       # seconds per manifest
      verify_parallelism: 8     # GUARDDOG_PARALLELISM for verify, 1 to 64
      sandbox: auto             # auto | required | disabled
      rules: []                 # run only these rules
      exclude_rules: []         # or skip these
      include_capabilities: false
      excluded_paths: []        # [{path: "vendor/**", reason: "..."}]
      max_hits: null            # GuardDog's per-rule limits; 0 removes them
      scan_timeout: 1800        # seconds per package root
      tool_version: null        # default "==3.2.0"
      install_timeout: 300      # seconds for the uv install, and for each
                                # `list-rules` call when rules/exclude_rules is set
      severity_threshold: null  # this scanner's override of the global threshold

Known limitations

  • GuardDog's extension ecosystem (editor extensions) is not offered: its manifest is an ordinary package.json and cannot be told apart from an npm package.
  • A file reached only through a symlink is not scanned.
  • The staging copy goes in a new directory under the system temporary directory, outside the scanned directory and ASH's output directory, so that a scanner that walks the scanned tree (trivy-repo does) never lists it, and is removed after the scan. Under --sandbox the sandbox gives GuardDog read-only access to it. When the temporary directory is itself inside either of those directories, the copy goes in GuardDog's results directory instead and ASH logs a warning; set TMPDIR to a directory outside both. It is a copy of each package root's files, never hard links. For a repository with a root pyproject.toml or package.json that is most of the repository.
  • verify findings are located on the first manifest line naming the dependency, because GuardDog's JSON does not record where a dependency is declared.
  • When any invocation fails, the scanner's findings appear in its own SARIF file but not in the aggregated reports, because the scanner's status is ERROR.
  • By default GuardDog stops a rule after the number of hits its rule metadata allows (max_hits: 1, 3 or 5 for the source-code rules in GuardDog 3.2.0) in each package root, walking the files in sorted order. A package root with more matches than that reports only the first ones, so the results show what GuardDog flagged, not every line that matches its rules. The cut is deterministic, so the same tree gives the same results; an ASH suppression does not free a slot, because GuardDog applies the limit before ASH sees the results. options.max_hits raises or removes the limit; see How many matches GuardDog reports.
  • options.max_hits does not reach the dependency scan GuardDog starts itself for the npm risky_new_dependency rule under verify, which keeps GuardDog's own limits. That scan only decides whether the rule fires.