https://github.com/crowdstrike/container-image-scan

Code to scan a container with CrowdStrike and return response codes indicating pass/fail status.

https://github.com/crowdstrike/container-image-scan

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.7%) to scientific vocabulary

Keywords from Contributors

scripts charts sensor falcon crowdstrike powershell container operator cicd crowdstrike-apis
Last synced: 11 months ago · JSON representation

Repository

Code to scan a container with CrowdStrike and return response codes indicating pass/fail status.

Basic Info
  • Host: GitHub
  • Owner: CrowdStrike
  • License: mit
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 174 KB
Statistics
  • Stars: 38
  • Watchers: 9
  • Forks: 25
  • Open Issues: 15
  • Releases: 16
Created over 5 years ago · Last pushed about 1 year ago
Metadata Files
Readme License

README.md

[!WARNING] DEPRECATED: This repository is deprecated and will no longer receive updates. Please migrate to the new CrowdStrike FCS Action for future container image scanning needs.

CrowdStrike Container Image Scan Flake8

This script will scan a container and return response codes indicating pass/fail status.

Specifically, this script:

  1. Tags your image using docker tag or podman tag
  2. Authenticates to CrowdStrike using your OAuth2 API keys
  3. Pushes your image to CrowdStrike for evaluation using docker push, after which CrowdStrike performs an Image Scan
  4. Parses returned scan report, generating return error codes as needed

All output is sent to stdout/stderr.

Prerequisites

  • Docker or Podman installed and running
  • Python3 and pip installed
  • CrowdStrike OAuth2 API keys with appropriate permissions (see below)

OAuth2 API Key Prerequisites

A CrowdStrike OAuth2 API keys with the following permissions is required:

| Permission | Needed scopes | | ---------------------- | ------------------ | | Falcon Container Image | read and write |

Installation

Choose ONE of the following installation methods based on your container runtime:

Option 1: Docker Installation

If you're using Docker:

shell pip3 install docker crowdstrike-falconpy retry

Option 2: Podman Installation

If you're using Podman:

shell pip3 install podman crowdstrike-falconpy retry

Important Podman Configuration Notes

  1. For rootless Podman, ensure the podman socket is running:

shell systemctl --user start podman.socket

  1. For rootful Podman, ensure the following:

shell # The socket is running systemctl start podman.socket # Set the container host environment variable export CONTAINER_HOST="unix:///var/run/podman/podman.sock"

Option 3: Complete Installation

To install support for both Docker and Podman:

[!NOTE] If using Podman, follow the Podman Configuration Notes above after installing the requirements.

shell pip3 install -r requirements.txt

Usage

```shell $ python3 csscanimage.py --help usage: csscanimage.py [-h] -u CLIENT_ID -r REPO [-t TAG] [-c {us-1,us-2,eu-1,us-gov-1}] [-s SCORE] [--json-report REPORT] [--log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}] [-R RETRY_COUNT] [--plugin] [--user-agent USERAGENT]

optional arguments: -h, --help show this help message and exit --json-report REPORT Export JSON report to specified file --log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL} Set the logging level --plugin Prints the report as json to stdout --user-agent USERAGENT HTTP User agent to use for API calls

required arguments: -u CLIENTID, --clientid CLIENTID Falcon OAuth2 API ClientID -r REPO, --repo REPO Container image repository -t TAG, --tag TAG Container image tag -c {us-1,us-2,eu-1,us-gov-1}, --cloud-region {us-1,us-2,eu-1,us-gov-1} CrowdStrike cloud region -s SCORE, --scorethreshold SCORE Vulnerability score threshold -R RETRYCOUNT, --retrycount RETRYCOUNT Scan report retry count ```

[!NOTE] CrowdStrike Falcon API credentials may be supplied also by the means of environment variables:

FALCON_CLIENT_ID, FALCON_CLIENT_SECRET, and FALCON_CLOUD_REGION.

Establishing and retrieving API credentials can be performed at https://falcon.crowdstrike.com/support/api-clients-and-keys.

Example Scans

Example 1

```shell python csscanimage.py --clientid FALCONCLIENTID --repo --tag --cloud-region <cloudregion>

please enter password to login Password: ```

The command above will return output similar to:

shell INFO Downloading Image Scan Report INFO Searching for vulnerabilities in scan report... INFO Searching for leaked secrets in scan report... INFO Searching for malware in scan report... INFO Searching for misconfigurations in scan report... WARNING Alert: Misconfiguration found INFO Vulnerability score threshold not met: '0' out of '500'

Example 2

The script provided was built to score vulnerabilities on a scale show below.

critical_score = 2000 high_score = 500 medium_score = 100 low_score = 20

The default value to return a non-zero error code for vulnerabilties is one high vulnerabilty. This can be overridden by providing the -s parameters to the script.

The example below will accomodate vulnerabilities with a sum of 1500.

```shell python csscanimage.py --clientid FALCONCLIENTID --repo --tag \ --cloud-region <cloudregion> -s 1500

```

The echo $? command can be utilized to review the return code, e.g:

shell echo $? 1

The echo $? above displays the returned code with the following mappings:

shell VulnerabilityScoreExceeded = 1 Malware = 2 Secrets = 3 Success = 0 Misconfig = 0 ScriptFailure = 10

Running the Scan using CICD

Using the container-image-scan Container

```shell export FALCONCLIENTID= export FALCONCLIENTSECRET=

docker run -it --rm -e FALCONCLIENTID -e FALCONCLIENTSECRET \ -v /var/run/docker.sock:/var/run/docker.sock \ quay.io/crowdstrike/container-image-scan:latest --repo --tag ```

You can use any argument that is supported by the script. For example, to set the cloud region:

shell docker run -it --rm -e FALCON_CLIENT_ID -e FALCON_CLIENT_SECRET \ -v /var/run/docker.sock:/var/run/docker.sock \ quay.io/crowdstrike/container-image-scan:latest --repo <repo> --tag <tag> -c us-2

Owner

  • Name: CrowdStrike
  • Login: CrowdStrike
  • Kind: organization
  • Email: github@crowdstrike.com
  • Location: United States of America

GitHub Events

Total
  • Create event: 4
  • Issues event: 1
  • Release event: 2
  • Watch event: 5
  • Delete event: 2
  • Push event: 8
  • Pull request event: 14
  • Fork event: 3
Last Year
  • Create event: 4
  • Issues event: 1
  • Release event: 2
  • Watch event: 5
  • Delete event: 2
  • Push event: 8
  • Pull request event: 14
  • Fork event: 3

Committers

Last synced: about 1 year ago

All Time
  • Total Commits: 118
  • Total Committers: 14
  • Avg Commits per committer: 8.429
  • Development Distribution Score (DDS): 0.788
Past Year
  • Commits: 13
  • Committers: 3
  • Avg Commits per committer: 4.333
  • Development Distribution Score (DDS): 0.308
Top Committers
Name Email Commits
Gabe Alford r****s@g****m 25
Simon Lukasik s****k@c****m 20
ffalor 3****r 18
Bryan McClellan m****s@g****m 12
Carlos Matos c****s@c****m 10
dependabot[bot] 4****] 9
Joshua Hiller j****r@c****m 7
Shawn Wells s****n@s****o 7
TomRyan-321 2****1 3
Derek Olsen d****n@c****m 2
Ashwin Athalye a****e@c****m 2
falcon-pioupiou f****u 1
Ibrahim Kunduraci i****y@g****m 1
a-sarja a****a@g****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 11 months ago

All Time
  • Total issues: 19
  • Total pull requests: 84
  • Average time to close issues: 2 months
  • Average time to close pull requests: 3 days
  • Total issue authors: 13
  • Total pull request authors: 19
  • Average comments per issue: 1.37
  • Average comments per pull request: 0.52
  • Merged pull requests: 69
  • Bot issues: 0
  • Bot pull requests: 12
Past Year
  • Issues: 1
  • Pull requests: 12
  • Average time to close issues: N/A
  • Average time to close pull requests: about 3 hours
  • Issue authors: 1
  • Pull request authors: 4
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 7
  • Bot issues: 0
  • Bot pull requests: 2
Top Authors
Issue Authors
  • jmckenzie-cs (3)
  • ffalor (3)
  • mccbryan3 (2)
  • atul-bhardwaj-sp (2)
  • zach-griffin (1)
  • Johnnydtech (1)
  • rogerwws (1)
  • gaahrdner (1)
  • Epoxboy (1)
  • jhuan4 (1)
  • mochacat (1)
  • snazy2000 (1)
  • JtMotoX (1)
Pull Request Authors
  • redhatrises (23)
  • dependabot[bot] (14)
  • ffalor (12)
  • isimluk (11)
  • carlosmmatos (7)
  • mccbryan3 (5)
  • shawndwells (3)
  • falcon-pioupiou (3)
  • someword (3)
  • jeff-hegerhorst-deepsee (2)
  • JtMotoX (2)
  • TomRyan-321 (2)
  • lgtm-com[bot] (1)
  • jshcodes (1)
  • a-sarja (1)
Top Labels
Issue Labels
enhancement (2)
Pull Request Labels
dependencies (15) python (6) enhancement (4) bugfixes (2) bug (2)

Dependencies

setup.py pypi
  • docker *
  • requests *
.github/workflows/linting.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/release.yml actions
  • actions/checkout v3 composite
  • ncipollo/release-action v1 composite
Dockerfile docker
  • gcr.io/distroless/python3-debian11 latest build
  • python 3.9 build
Pipfile pypi
  • crowdstrike-falconpy *
  • docker *
Pipfile.lock pypi
  • certifi ==2022.6.15
  • charset-normalizer ==2.1.1
  • crowdstrike-falconpy ==1.2.0
  • docker ==6.0.0
  • idna ==3.3
  • packaging ==21.3
  • pyparsing ==3.0.9
  • requests ==2.28.1
  • urllib3 ==1.26.12
  • websocket-client ==1.4.1