Comment on page
Filtering output
Customize the output format of verdicts
lstn
scan results can be filtered through various methods, allowing for a flexible range of use cases. For example:- Whitelisting packages: lstn can ignore dependencies by name and type. If configured, the applicable packages will not be included in the scan.
- Defining rule-based policy: the required context from verdicts can be filtered and used to assert policies. For example, blocking a CI build in case of a dependency with
"priority": "critical"
. Read more about policies here. - Building workflows on top of verdicts: examples include integration with a reporting tool, writing to a database, or visualization in a dashboard.
See the options below to configure lstn based on your needs:
For example:
lstn scan --ignore-deptypes=dev --ignore-packages=lodash,react
This feature only works for
lstn scan
at the moment....
filtering:
ignore:
packages:
- "donotprocessme"
- "react"
deptypes:
- "peer"
LSTN_IGNORE_DEPTYPES=peer,optional
LSTN_IGNORE_PACKAGES=react,@vue/devtools
lstn
scan results can produce JSON
output using the --json
flag. The JSON output can be filtered through jq
expressions through a built-in utility accessible through the -q
flag. Below are some examples of how the output of
lstn
commands can be filtered using jq
expressions:To return only the packages that have a verdict, use the following command:
lstn to <package-name> --json -q '.[] | select(.verdicts != [])'
To return only the packages for a specific priority level, use the following command:
lstn to <package name> --json -q '.[] | .verdicts[] | select(.priority == "<priority level>")’
For example,
lstn to jq --json -q '.[] | .verdicts[] | select(.priority == "critical")’
To return only the packages that have a verdict, use the following command:
lstn scan <project directory> --json -q select(.name == "<package name>")
For example,
lstn to jq --json -q -c select(.name == "lodash")'
To get all verdicts for a specified message, use the following command:
lstn to <package name> --json -q '.[] | .verdicts[] | select(.message == "unexpected outbound connection destination")’
Replace the
<package name>
with your desired package, and "unexpected outbound connection destination"
with the message you want to retrieve verdicts for. The output of this command will be a list of verdicts for the specified message.To return only the packages that have a verdict, use the following command:
lstn to <package name> --json -q '.[] | .verdicts[] | .metadata | select(.<metadata key> == <metadata-value>)’
Replace the
443
with the metadata value you want to retrieve verdicts for. The output of this command will be a list of verdicts for the specified metadata value.For example
lstn to jq
--json -q '.[] | .verdicts[] | .metadata | select(.server_port == 443)’
To return only the packages that have a verdict, use the following command:
lstn --json -q '.[] | .name’
To return only the packages that have a verdict, use the following command:
lstn --json -q '.[] | .verdicts'
This combination outputs only packages with verdicts.
Last modified 7mo ago