Technical Documentation: microsoft/ApplicationInspector
โน๏ธ Provenance: Multi-Tier Ingestion ยท CodeWiki Reference
Overview (`README.md`)
Introduction
Microsoft Application Inspector is a software source code characterization tool that helps identify coding features of
first or third party software components based on well-known library/API calls and is helpful in security and
non-security use cases. It uses hundreds of rules and regex patterns to surface interesting characteristics of source
code to aid in determining what the software is or what it does from what file operations it uses, encryption,
shell operations, cloud API's, frameworks and more and has received industry attention as a new and valuable
contribution to OSS
on ZDNet, SecurityWeek
, CSOOnline
, Linux.com/news
, HelpNetSecurity, Twitter and more and was first featured
on Microsoft.com.
Application Inspector is different from traditional static analysis tools in that it doesn't attempt to identify "good"
or "bad" patterns; it simply reports what it finds against a set of over 400 rule patterns for feature detection
including features that impact security such as the use of cryptography and more. This can be extremely helpful in
reducing the time needed to determine what Open Source or other components do by examining the source directly rather
than trusting to limited documentation or recommendations.
The tool supports scanning various programming languages including C, C++, C#, Java, JavaScript, HTML, Python,
Objective-C, Go, Ruby, PowerShell
and more and can scan projects with
mixed language files. It supports generating results in HTML, JSON and text output formats with the default being an
HTML report similar to the one shown here.
Be sure to see our complete project wiki page https://Github.com/Microsoft/ApplicationInspector/wiki for additional
information and help.
Quick Start
Obtain Application Inspector
.NET Tool (recommended)
- Download and install the .NET 6 SDK
- Run
dotnet tool install --global Microsoft.CST.ApplicationInspector.CLI
See more in the wiki
Platform Dependent Binary
- Download Application Inspector by selecting the pre-built package for the operating system of choice shown under the
Assets section
of the Releases.
Run Application Inspector
- Nuget Tool:
appinspector analyze -s path/to/src. - Platform Specific:
applicationinspector.cli.exe analyze -s path/to/src
Goals
Microsoft Application Inspector helps you in securing your applications from start to deployment.
Design Choices - Enables you to choose which components meet your needs with a smaller footprint of unnecessary or
unknowns features for keeping your application attack surface smaller as well as help to verify expected ones i.e.
industry standard crypto only.
Identifying Feature Deltas - Detects changes between component versions which can be critical for detecting
injection of backdoors.
Automating Security Compliance Checks - Use to identify components with features that require additional security
scrutiny, approval or SDL compliance as part of your build pipeline or create a repository of metadata regarding all of
your enterprise application.
Contribute
We have a strong default starting base of Rules for feature detection. But there are many feature identification
patterns yet to be defined and we invite you to submit ideas on what you want to see or take a crack at defining a
few. This is a chance to literally impact the open source ecosystem helping provide a tool that everyone can use. See
the Rules section of the wiki for more.
Official Releases
Application Inspector is in GENERAL AUDIENCE release status. Your feedback is important to us. If you're interested in
contributing, please review the CONTRIBUTING.md.
Application Inspector is available as a command line tool or NuGet package and is supported on Windows, Linux, or MacOS.
Platform specific binaries of the ApplicationInspector CLI are available on our
GitHub releases page.
The C# library is available on NuGet
as Microsoft.CST.ApplicationInspector.Commands
.
The .NET Global Tool is available on NuGet
as Microsoft.CST.ApplicationInspector.CLI.
If you use the .NET Core version, you will need to have .NET 6.0 or later installed. See
the JustRunIt.md
or Build.md files for more.
CLI Usage Information
> appinspector --help
ApplicationInspector.CLI 1.8.4-beta+976ee3cdd1
c Microsoft Corporation. All rights reserved.
analyze Inspect source directory/file/compressed file (.tgz|zip)
against defined characteristics
tagdiff Compares unique tag values between two source paths
exporttags Export the list of tags associated with the specified rules.
Does not scan source code.
verifyrules Verify custom rules syntax is valid
packrules Combine multiple rule files into one file for ease in
distribution
help Display more information on a specific command.
version Display version information.Examples:
Command Help
To get help for a specific command run appinspector <command> --help.
Analyze Command
The Analyze Command is the workhorse of Application Inspector.
Simple Default Analyze
This will produce an output.html of the analysis in the current directory using default arguments and rules.
appinspector analyze -s path/to/filesOutput Sarif
appinspector analyze -s path/to/files -f sarif -o output.sarifOutput Markdown
This will create a markdown output suitable for CI environments with a summary of key features.
appinspector analyze -s path/to/files -f markdown -o report.mdExcluding Files using Globs
This will create a json output named data.json of the analysis in the current directory, excluding all files in test
and .git folders using the provided glob patterns.
appinspector analyze -s path/to/files -o data.json -f json -g **/tests/**,**/.git/**Additional Usage Information
For additional help on use of the console interface
see CLI Usage.
For help using the NuGet package
see NuGet Support
Build Instructions
See build.md
Privacy
Usage of this application is governed by the Microsoft Privacy Statement.
Overview (`AppInspector/rules/samples/README.md`)
Application Inspector Sample Rules
This directory contains comprehensive sample rules that demonstrate all available fields and features for creating custom Application Inspector rules.
Files
comprehensive_sample_rule.json
A maximally specified sample rule file that demonstrates:
- All top-level rule fields: id, name, description, tags, severity, applies_to, does_not_apply_to, applies_to_file_regex, exclude_file_regex, depends_on_tags, overrides
- Pattern matching types: regex, regexword, string
- Pattern features: scopes, modifiers, confidence levels
- Conditions: same-file matching with both positive and negative conditions
- Self-testing: must-match and must-not-match arrays for validation
- Structured data queries: XPath for XML, JSONPath for JSON, YAMLPath for YAML
- Comments: Using _comment fields for documentation
Usage
These sample rules are for reference and learning purposes. They demonstrate the full capabilities of the Application Inspector rule format.
To use these samples:
- Copy and modify them for your specific detection needs
- Adjust the patterns to match your target code constructs
- Update the tags to fit your categorization scheme
- Set appropriate severity levels
- Add must-match/must-not-match test cases to validate your rules
Field Descriptions
Required Fields
id: Unique identifier for the rule (e.g., "AI001234")name: Human-readable name describing what the rule detectstags: Array of categorization tags (at least one required)patterns: Array of search patterns (at least one required)
Optional Fields
description: Detailed description of what the rule detectsseverity: One of: critical, important, moderate, bestpractice, manualreview, unspecified (lowercase preferred; default: moderate)applies_to: Array of file extensions or language identifiersdoes_not_apply_to: Array of file extensions or language identifiers to excludeapplies_to_file_regex: Array of regex patterns for files to includeexclude_file_regex: Array of regex patterns for files to excludedepends_on_tags: Array of tags that must be present for this rule to applyoverrides: Array of rule IDs that this rule supersedesconditions: Array of additional matching conditionsexpression: Boolean expression combining pattern and condition labels (see Expressions)must-match: Array of test strings that should match (for validation)must-not-match: Array of test strings that should not match (for validation)_comment: Optional comment for documentation
Pattern Fields
pattern: The regex/string pattern to search for (required)type: One of: regex (default), regexword, string, substringlabel: Name for this pattern, for use inexpression(default: the pattern's index)conditions: Array of conditions that gate only this pattern's findingsscopes: Array of: code, comment, all, htmlconfidence: One of: high, medium, low, unspecifiedmodifiers: Array of regex modifiers: i, m, s, x (or full names)xpaths: Array of XPath expressions for XML matchingjsonpaths: Array of JSONPath expressions for JSON matchingymlpaths: Array of YAMLPath expressions for YAML matching_comment: Optional comment for documentation
Condition Fields
pattern: A pattern object (same structure as patterns array)search_in: Where to search - "finding-region(-offset,length)", "finding-only", "same-line", "same-file", "only-before", "only-after"negate_finding: Boolean - if true, the finding is invalid if this condition matcheslabel: Name for this condition, for use inexpression(default: the condition's clause index)applies_to: Array of languages this condition applies to (default: all)does_not_apply_to: Array of languages this condition does not apply to_comment: Optional comment for documentation
Expressions
By default a rule matches when any pattern matches and every rule level condition holds:
(pattern0 OR pattern1 OR ...) AND condition0 AND condition1 ...Two optional features let you go beyond that shape.
Scoping a condition to one pattern
Declare the condition on the pattern it guards rather than at rule level. Other patterns are unaffected,
so they still report even when the condition excludes this pattern's finding.
"patterns": [
{
"pattern": "curl", "type": "substring", "label": "curl",
"conditions": [
{
"pattern": { "pattern": "--tlsv1.3", "type": "substring" },
"search_in": "same-line",
"negate_finding": true
}
]
},
{ "pattern": "wget", "type": "substring", "label": "wget" }
]Writing the expression yourself
Set expression to combine labels with AND, OR, XOR, NAND, NOR and NOT. This makes
otherwise inexpressible rules possible, such as a disjunction of conditions or a negated conjunction:
"expression": "cookie AND NOT (secure AND httponly)"That rule fires when either required flag is missing. Writing it as two negated conditions would
instead mean "neither flag is present", which stays silent on partially hardened code.
Every finding is judged against the expression on its own. A file containing one correctly hardened
cookie and one missing a flag reports the second, because the first satisfying secure AND httponly
says nothing about the second.
Because a finding originates from exactly one pattern, every other pattern label is false while
that finding is judged. An expression over pattern labels alone can therefore select which patterns
originate findings, but it cannot require sibling patterns to co-occur: a AND NOT b reports exactly
what a reports. Conditions add co-occurrence tests because they are evaluated against each finding
and can be true or false independently of it.
Requiring that two patterns both appear
This is why verification rejects an expression that needs two pattern labels true at once, such asa AND b. That is a normal-form requirement rather than a restriction on AND: a condition is a
pattern plus a search window, so a term that only has to co-occur is written as a same-file
condition instead.
"expression": "p AND ois",
"patterns": [
{ "pattern": "readObject", "type": "substring", "label": "p", "scopes": [ "code" ] }
],
"conditions": [
{ "pattern": { "pattern": "ObjectInputStream", "type": "substring", "scopes": [ "code" ] },
"search_in": "same-file", "label": "ois" }
]That reports each readObject, but only in a file that also contains ObjectInputStream.
To report the locations of both terms, declare each one twice, once as a pattern so it can
originate a finding and once as a same-file condition so it can constrain the other:
"expression": "(a OR b) AND ca AND cb"with patterns a and b, and same-file conditions ca and cb carrying those same two patterns.
Every a and every b is then reported, but only in files that contain both.
Expressions have no operator precedence. They are evaluated strictly left to right, so
a OR b AND cmeans(a OR b) AND c, nota OR (b AND c). Always use parentheses to make
grouping explicit; rule verification rejects an expression that mixes operators at the same level
without them.
Other rules for expressions:
- Labels may not contain spaces or parentheses, and must be unique within the rule.
- Every label named in the expression must belong to a pattern or condition in the same rule.
- Attach parentheses to labels:
(a OR b)is valid,( a OR b )is not. - Parentheses must be balanced.
- A rule that sets
expressionmust express negation withNOTrather thannegate_finding. - Conditions test captured pattern findings independently of label order in the expression. For example,
c AND aanda AND care equivalent whencis a condition andais a pattern.
Best Practices
- Use lowercase for enums: severity, type, confidence, and scopes should use lowercase values
- Populate optional fields: Only include optional fields like
recommendationor_commentif they contain meaningful content - Test your rules: Always include must-match and must-not-match examples
- Use appropriate severity: Choose severity levels that reflect the actual impact
- Use specific patterns: Make patterns as specific as possible to reduce false positives
- Document with comments: Use
_commentfields to explain complex patterns or conditions - Parenthesise expressions: Expressions fold left to right with no precedence, so group explicitly
Related Documentation
--- METRICS ---
- Files Extracted: 2
- Estimated Token Budget: ~4230 tokens
- Canonical Reference: https://codewiki.google/github.com/microsoft/ApplicationInspector