Detector layouts
The layout each built-in detector follows: one pure parser per file type, rules from a bundled registry, and a documented boundary. The authoring guide starts at Detector authoring.
Ruby detector layout
The Ruby detector is a useful example of the layout a built-in detector follows. Its entry point, src/detectors/ruby/index.ts, finds the files, reads them, and matches each declaration to a rule. One pure parser per file type sits beside it (parse-ruby-runtime.ts, parse-gemfile.ts, parse-gemfile-lock.ts, and parse-gemspec.ts):
- A parser returns nothing, not an error, for a form it does not support, and never returns part of a malformed file or line.
- Rules come from
registry/ruby.json, loaded through the bundled data. The detector takes a rule loader so tests can supply their own rules. - A runtime pin uses the first rule whose
versrange contains the version. A rule whoseversis malformed is skipped, so it does not hide a later rule. - A
Gemfilegem is matched only against rules that cover every version, while aGemfile.lockgem is matched against any rule for that gem name. - Gem rules that declare usage matchers use
analyzeSourceUsage, so those findings list the Ruby files that import or call the gem. Arequire,load,gem, orautoloadwhose argument is not a string literal is unclassified.require_relativeis never unclassified. Qualified calls without parentheses (for exampleJSON.parse text) are not matched.
The user-facing list of supported forms and limits for this detector is in Compatibility.
PHP detector layout
The PHP detector follows the same layout. Its entry point, src/detectors/php/index.ts, finds the files, reads them, and matches each declaration to a rule. One pure parser per file type sits beside it (parse-php-runtime.ts, parse-composer-json.ts, and parse-composer-lock.ts):
- A parser returns nothing, not an error, for a form it does not support, and never returns part of a malformed file or line.
- Rules come from
registry/php.json, loaded through the bundled data. The detector takes a rule loader so tests can supply their own rules. - A runtime pin uses the first rule whose
versrange contains the version. A constraint that is not a concrete version (for example>=7.4or^8.2) is skipped, and a rule whoseversis malformed is skipped, so neither hides a later rule. - A
composer.jsonpackage is matched only against rules that cover every version of the package, while acomposer.lockpackage is matched against any rule whoseverscontains the resolved version. Anabandonedflag in the lockfile is recorded by the parser and is not itself a finding. - Package rules that declare usage matchers use
analyzeSourceUsage, so those findings list the.phpfiles thatrequireorincludethat package and the qualified calls those matchers name. Arequireorincludewhose argument is not a string literal is unclassified, as isnew $classor$class::method(). Runtime end-of-life rules do not name source usages.
The user-facing list of supported forms and limits for this detector is in Compatibility.
Android detector layout
The Android detector follows the same layout. Its entry point, src/detectors/android/index.ts, finds the files, reads them, and matches each declaration to a rule. Pure parsers sit beside it: parse-build-gradle.ts for SDK settings, parse-settings-gradle.ts for plugin pins, and parse-libs-versions-toml.ts for the version catalog. String-notation Maven dependencies in build.gradle and build.gradle.kts come from the Java detector’s parse-gradle.ts; this detector keeps only those dependency declarations.
- A parser returns nothing, not an error, for a form it does not support, and never returns part of a malformed file.
- Rules come from
registry/android.json, loaded through the bundled data. The detector takes a rule loader so tests can supply their own rules. - A declaration uses the first rule whose
versrange contains the version text. A rule whoseversis malformed, or whose comparison throws, is skipped, so it does not hide a later rule. - An SDK setting matches
pkg:generic/android/<kind>(compileSdk,minSdk,targetSdk,buildToolsVersion). An Android Gradle Plugin pin, in settings or the catalogagpkey, matchespkg:generic/android/agp.org.jetbrains.kotlin.androidin settings matchespkg:generic/android/kotlin-android. The catalogkotlinkey matchespkg:generic/android/kotlin. A string-notation dependency matchespkg:maven/<group>/<artifact>. - Property references, method calls, version-catalog lookups, and
$interpolation produce no declaration. The analysis reports no unclassified references. - A rule that lists usage matchers uses
analyzeSourceUsagefor.javaand.ktfiles. The bundled Play Billing rules do not list matchers, so those findings point at the declaration only.
The user-facing list of supported forms and limits for this detector is in Compatibility.
CI runner images detector layout
The CI runner images detector follows the same layout. Its entry point, src/detectors/ci-images/index.ts, finds the files, reads them, and matches Azure hosted-image labels to a rule. One pure parser per file type sits beside it (parse-gitlab-ci.ts, parse-circleci.ts, and parse-azure-pipelines.ts):
- A parser returns nothing, not an error, for a form it does not support, and never returns part of a malformed file.
- Rules come from
registry/ci-images.json, loaded through the bundled data. The detector takes a rule loader so tests can supply their own rules. - An Azure
pool.vmImagelabel of the formubuntu-<version>,macos-<version>, orwindows-<version>matchespkg:generic/azure-pipelines/<family>-imagewith anintdotversion. Every rule whoseversrange contains that version is reported. A label with an architecture suffix, or any other shape, is not matched. - GitLab
imageandservicesvalues are always unclassified. CircleCI returns orbs, dynamic values, and floating aliases as unclassified; a literal CircleCI image is not matched, because this version has no CircleCI Package URL mapping. latest,*-latest, variables, and template expressions produce no finding. There is no source-usage pass.
The user-facing list of supported forms and limits for this detector is in Compatibility.
Dart detector layout
The Dart detector follows the same layout. Its entry point, src/detectors/dart/index.ts, finds the files, reads them, and matches each declaration to a rule. One pure parser per file type sits beside it (parse-pubspec.ts, parse-pubspec-lock.ts, and parse-fvm.ts):
- Rules come from
registry/dart.json, loaded through the bundled data. The detector takes a rule loader so tests can supply their own rules. - An exact version (a
pubspec.lockpackage, an FVM pin, or a constraint without an operator) uses the first rule whoseversrange contains it. A constraint with an operator is matched only against rules that cover every version of that package. A rule whoseversis malformed is skipped, so it does not hide a later rule. - Rules that declare usage matchers use
analyzeSourceUsage, so those findings list the.dartfiles that import the package and the calls those matchers name.Function.applyanddart:mirrorsreflection are unclassified.
The user-facing list of supported forms and limits for this detector is in Dart and Flutter.
Database runtimes detector layout
The database detector reuses what the container and Terraform detectors already parse. Its entry point, src/detectors/database/index.ts, finds Compose and *.tf files, reads them, and matches each declaration to a rule. Two pure parsers sit beside it: parse-compose.ts filters the shared Compose image parser to database images, and parse-terraform.ts reads engine and engine_version with the shared HCL scanner:
- A parser returns nothing, not an error, for a form it does not support, and never returns part of a malformed file.
- Rules come from
registry/database.json, loaded through the bundled data. The detector takes a rule loader so tests can supply their own rules. - A full version uses the first rule whose
versrange contains it. A partial version (12,5.7) matches a rule only when the rule contains both ends of what the partial version could mean. A rule whoseversis malformed is skipped, so it does not hide a later rule. - Each product maps to one Package URL (
pkg:generic/postgresql,mysql,mariadb,redis,mongodb). There is no source-usage pass.
The user-facing list of supported forms and limits for this detector is in Database runtimes.
Shell and PowerShell detector layout
The shell detector reads PowerShell declarations and the PowerShell image tags in workflow files. Its entry point, src/detectors/shell/index.ts, finds *.ps1, *.psm1, *.psd1, and .github/workflows files, reads them, and matches each declaration to a rule. Two pure parsers sit beside it: parse-powershell.ts is a bounded lexical reader for #Requires -Version and PowerShellVersion, and parse-workflow.ts reads shell: values and pinned PowerShell or Bash images from workflow YAML.
- A parser returns nothing, not an error, for a form it does not support, and never returns part of a malformed file.
- Rules come from
registry/shell.json, loaded through the bundled data. The detector takes a rule loader so tests can supply their own rules. - Matching works as in the database detector: a full version uses the first rule whose
versrange contains it, and a partial version matches only when the rule contains both ends of what it could mean. - All rules use one Package URL,
pkg:generic/powershell. Shell names and Bash images are parsed but produce no findings. There is no source-usage pass.
The user-facing list of supported forms and limits for this detector is in Shell and PowerShell.
Terraform detector layout
The Terraform detector follows the same layout. Its entry point, src/detectors/terraform/index.ts, finds the files, reads them, and matches each declaration to a rule. One pure parser per file type sits beside it (parse-terraform.ts, parse-lock.ts, and parse-version-files.ts), on top of the shared bounded scanner in hcl.ts:
- A parser returns nothing, not an error, for a form it does not support, and never returns part of a malformed file.
- Rules come from
registry/terraform.json, loaded through the bundled data. The detector takes a rule loader so tests can supply their own rules. - An exact version (a version file, a lock entry, or a constraint without an operator) uses the first rule whose
versrange contains it. A~> X.Y.Zconstraint matches a rule that contains both ends of that minor line. Any other constraint is matched only against rules that cover every version. A rule whoseversis malformed is skipped, so it does not hide a later rule. - The Terraform CLI is
pkg:generic/terraformand a provider ispkg:generic/terraform-provider/<namespace>/<name>. There is no source-usage pass.
The user-facing list of supported forms and limits for this detector is in Terraform.
Swift detector layout
The Swift detector follows the same layout. Its entry point, src/detectors/swift/index.ts, finds the files, reads them, and matches each declaration to a rule. One pure parser per file type sits beside it (parse-swift-toolchain.ts, parse-package-swift.ts, parse-package-resolved.ts, and parse-xcode-project.ts):
- A parser returns nothing, not an error, for a form it does not support, and never returns part of a malformed file or line.
- Rules come from
registry/swift.json, loaded through the bundled data. The detector takes a rule loader so tests can supply their own rules. - An exact pin (
.xcode-version,.swift-version,swift-tools-version,exact:inPackage.swift, aPackage.resolvedversion, or an app-targetIPHONEOS_DEPLOYMENT_TARGET) uses the first rule whoseversrange contains the version. A rule whoseversis malformed is skipped, so it does not hide a later rule. - A
from:requirement inPackage.swiftis matched only against rules that cover every version of that package. Package identity is the lowercased repository name without.git, matching what SwiftPM writes inPackage.resolved. - The iOS deployment target is read only from application targets in
project.pbxproj(com.apple.product-type.application), so a library or aplatforms:minimum inPackage.swiftnever produces that finding. - Package rules that declare usage matchers use
analyzeSourceUsage, so those findings list the.swiftfiles thatimportthat module and the qualified calls those matchers name. Runtime Objective-C lookup forms (NSClassFromString,Selector(…), and similar) are unclassified. Toolchain and App Store rules do not name source usages.
The user-facing list of supported forms and limits for this detector is in Swift.
C and C++ detector layout
The C and C++ detector follows the same layout. Its entry point, src/detectors/cpp/index.ts, finds the files, reads them, and matches each declaration to a rule. One pure parser per manifest sits beside it (parse-cmakelists.ts, parse-conan.ts, and parse-vcpkg.ts):
- A parser returns nothing, not an error, for a form it does not support, and never returns part of a malformed file.
- Rules come from
registry/cpp.json, loaded through the bundled data. The detector takes a rule loader so tests can supply their own rules. - A declaration with a version uses the first rule whose
versrange contains that version. A rule whoseversis malformed, or whose comparison throws, is skipped, so it does not hide a later rule. - A vcpkg dependency with no
version>=matches only a rule that covers every version of that package.cmake_minimum_requiredmatchespkg:generic/cmake. A Conan requirement matchespkg:conan/<name>. A vcpkg dependency matchespkg:vcpkg/<name>. Language standards, compiler checks, andbuiltin-baselinematch the generic Package URLs named in the detector. - Generator and module rules are not matched yet: the CMake parser does not emit those declarations. There is no source-usage pass.
The detector is supported. Its public corpus and the user-facing list of supported forms, lifecycle data sources, and limits are in C and C++ and Compatibility.
Serverless runtimes detector layout
The Serverless runtimes detector follows the same layout. Its entry point, src/detectors/serverless/index.ts, finds the files, reads them, and matches each literal runtime identifier to a rule. One pure parser per file type sits beside it (parse-template.ts, parse-serverless-yml.ts, and parse-tf.ts):
- A parser returns nothing, not an error, for a form it does not support, and never returns part of a malformed file.
- Rules come from
registry/serverless.json, loaded through the bundled data. The detector takes a rule loader so tests can supply their own rules. - Each literal identifier is tried against
pkg:generic/aws-lambda-runtime/<id>andpkg:generic/google-cloud-functions-runtime/<id>. The first rule whose VERS range contains the identifier wins. A rule whose VERS is malformed is skipped, so it does not hide a later rule. - CloudFormation tags (
!Ref,!Sub), Serverless${…}interpolations, Terraformvar/local/ interpolation values, and floating aliases such aslatestproduce no declaration. - There is no source-usage pass: a runtime finding points at the declaration only.
The user-facing list of supported forms and limits for this detector is in Serverless runtimes.