mainframe.rules

Attributes

Classes

Functions

empty_rule_corpus(→ dict[str, str])

Return an empty, typed rule corpus.

build_auth_header(→ dict[str, str])

Build authentication headers given the access token.

fetch_commit_hash(→ str)

Fetch the top commit hash of the given repository.

parse_zipfile(→ dict[str, str])

Parse a zipfile and return a dict mapping filenames to content.

parse_opengrep_rules(→ dict[str, str])

Return OpenGrep rules keyed by repository-relative paths.

fetch_zipfile(→ zipfile.ZipFile)

Download the source zipfile from GitHub for the given repository.

fetch_rules(→ Rules)

Return the commit hash and all the rules.

Module Contents

mainframe.rules.REPOSITORY: Final[str] = 'vipyrsec/security-intelligence'[source]
mainframe.rules.empty_rule_corpus() dict[str, str][source]

Return an empty, typed rule corpus.

class mainframe.rules.Rules[source]
rules_commit: str[source]
rules: dict[str, str][source]
opengrep_rules: dict[str, str][source]
mainframe.rules.build_auth_header(access_token: str) dict[str, str][source]

Build authentication headers given the access token.

mainframe.rules.fetch_commit_hash(http_client: httpx.Client, *, repository: str, access_token: str) str[source]

Fetch the top commit hash of the given repository.

mainframe.rules.parse_zipfile(zipfile: zipfile.ZipFile) dict[str, str][source]

Parse a zipfile and return a dict mapping filenames to content.

mainframe.rules.parse_opengrep_rules(zipfile: zipfile.ZipFile) dict[str, str][source]

Return OpenGrep rules keyed by repository-relative paths.

mainframe.rules.fetch_zipfile(http_client: httpx.Client, *, repository: str, access_token: str) zipfile.ZipFile[source]

Download the source zipfile from GitHub for the given repository.

mainframe.rules.fetch_rules(http_client: httpx.Client) Rules[source]

Return the commit hash and all the rules.