GitHub Advance Security Compliance Action

Overview

advanced-security-compliance

This Action was designed to allow users to configure their Risk threshold for security issues reported by GitHub Code Scanning, Secret Scanning and Dependabot Security.

Setup

Action

Here is how you can quickly setup advanced-security-compliance.

# Compliance
- name: Advance Security Compliance Action
  uses: GeekMasher/[email protected]

Action Examples

CLI

The CLI tool primarily using pipenv to manage dependencies and pip virtual environments to not mismatch dependencies.

# Install dependencies and virtual environment
pipenv install
# [option] Install system wide
pipenv install --system

Once installed, you can just call the module using the following command(s):

# Using pipenv script
pipenv run main --help
# ... or
pipenv run python -m ghascompliance

CLI Examples

Policy as Code / PaC

Here is an example of using a simple yet cross-organization using Policy as Code:

# Compliance
- name: Advance Security Compliance Action
  uses: GeekMasher/[email protected]
  with:
    # The owner/repo of where the policy is stored  
    policy: GeekMasher/security-queries
    # The local (within the workspace) or repository
    policy-path: policies/default.yml
    # The branch you want to target
    policy-branch: main

PaC Configuration file

The Policy as Code configuration file is very simple yet powerful allowing a user to define 4 types of rules per technologies you want to use.

# This is the technology you want to write a rule for
licensing:
  # The four main rules types to do everything you need to do for all things 
  #  compliance

  # Warnings will always occur if the rule applies and continues executing to 
  #  other rules.
  warnings:
    ids:
      - Other
      - NA
  # Ignores are run next so if an ignored rule is hit that matches the level, 
  #  it will be skipped
  ignores:
    ids:
      - MIT License
  # Conditions will only trigger and raise an error when an exact match is hit
  conditions:
    ids:
      - GPL-2.0
    names:
      - tunnel-agent

  # The simplest and ultimate rule which checks the severity of the alert and
  #  reports an issue if the level matches or higher (see PaC Levels for more info)
  level: error

PaC Levels

There are many different levels of severities with the addition of all and none (self explanatory). When a level is selected like for example error, all higher level severities (critical and high in this example) will also be added.

- critical
- high
- error
- medium
- moderate
- low
- warning
- notes

PaC Rule Blocks

For each rule you can choose either or both of the two different criteria's matches; ids and names

You can also use imports to side load data from other files to supplement the data already in the rule block

codescanning:
  conditions:
    # When the `ids` of the technologies/tool alert matches any one of the ID's in 
    #  the list specified, the rule will the triggered and report the alert.
    ids:
      # In this example case, the CodeQL rule ID below will always be reported if 
      #  present event if the severity is low or even note.
      - js/sql-injection

      # Side note: Check to see what different tools consider id's verses names,
      #  for example `licensing` considers the "Licence" name itself as the id 
      #  while the name of the package/library as the "name"
    
    # `names` allows you to specify the names of alerts or packages.
    names:
      - "Missing rate limiting"

    # The `imports` allows you to supplement your existing data with a list
    #  from a file on the system. 
    imports:
     ids: "path/to/ids/supplement/file.txt"
     names: "path/to/names/supplement/file.txt"

Wildcards

For both types of criteria matching you can use wildcards to easily match requirements in a quicker way. The matching is done using a Unix shell-style wildcards module called fnmatch which supports * for matching everything.

codescanning:
  conditions:
    ids:
      - '*/sql-injection'

Time to Remediate

The feature allows a user to define a time frame to which a security alert/vulnerability of a certain severity has before the alert triggered a violation in the Action.

By default, if this section is not defined in any part of the policy then no checks are done. Existing policy files should act the same without the new section.

general:
  # All other blocks will be inheriting the remediate section if they don't have 
  #  their own defined.
  remediate:
    # Only `error`'s and above have got 7 days to remediate according to the 
    #  policy. Any time before that, nothing will occur and post the remediation 
    #  time frame the alert will be raised. 
    error: 7

codescanning:
  # the `codescanning` block will inherit the `general` block
  # ...

dependabot:
  remediate:
    # high and critical security issues
    high: 7
    # moderate security issues
    moderate: 30
    # all other security issues
    all: 90

secretscanning:
  remediate:
    # All secrets by default are set to 'critical' severity so only `critical` 
    #  or `all` will work
    critical: 7
Time to Remediate Examples

Data Importing

Some things to consider when using imports:

  • Imports appending to existing lists and do not replace a previously generated list.
  • Imports are relative to:
    • Working Directory
    • GitHub Action / CLI directory
    • Cloned Repository Directory
  • Imports are only allowed from a number of predefined paths to prevent loading data on the system (AKA, path traversal).

Licensing Notice

MIT License

Copyright (c) 2021 Mathew Payne

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Comments
  • allow list

    allow list

    Description

    I am trying to define an allow list of licenses but using * under conditions isn't giving the desired result.

    image

    Propose Solution

    if I do the below the ignores are not actually ignoring anything as I am still

    licensing:
      # The four main rules types to do everything you need to do for all things
      #  compliance
    
      # Warnings will always occur if the rule applies and continues executing to
      #  other rules.
      warnings:
        ids:
          - other
          - na
    
      # Ignores are run next so if an ignored rule is hit that matches the level,
      #  it will be skipped
      ignores:
        ids:
          - apache license 2.0
          - bsd 3-clause "new" or "revised" license
          - mit license
    
      # Conditions will only trigger and raise an error when an exact match is hit
      conditions:
        # note using 'names' here instead of `ids` has the same result
        ids:
          - "*"
    
    enhancement 
    opened by lsmith77 4
  • Unknown Exception was hit, Error: Query failed to run

    Unknown Exception was hit, Error: Query failed to run

    Describe the bug Running this action on our workflow we get an error we can't understand.

    To Reproduce Steps to reproduce the behavior:

    1. Add action "build-and-test.yaml" to workflow
    2. With the following code: " advancesecurityComplience: runs-on: ubuntu-latest name: Advanced Security Complience steps:
    3. See error

    Dependabot Results Error: {"data": {"repository": {"vulnerabilityAlerts": null}}, "errors": [{"type": "FORBIDDEN", "path": ["repository", "vulnerabilityAlerts"], "extensions": {"saml_failure": false}, "locations": [{"line": 3, "column": 9}], "message": "Resource not accessible by integration"}]} Error: Unknown Exception was hit, please repo this to https://github.com/GeekMasher/advanced-security-Compliance Error: Query failed to run

    Expected behavior Dependabot to block the PR if finds a critical or high risk vulnerability.

    bug 
    opened by hmarnd 4
  • Add GitHub App API token authentication to clone custom policy inside a private repository

    Add GitHub App API token authentication to clone custom policy inside a private repository

    As stated in issue #50, the custom policy clone using GitHub App API token is not possible as x-access-tokenusername need to be set in the https clone link.

    I've added an optionnal argument --is-github-app-token to specify if the authentication token is a GitHub App API token, and set the x-access-token username needed to clone the policy.

    I've also added the branch argument to Policy()call, as it was actually never used.

    opened by 4bg0P 4
  • Dependabot scan fails with the default policy

    Dependabot scan fails with the default policy

    Describe the bug The Dependabot scan fails with the default policy. The repository does not have any open dependabot alerts, is that why?

    To Reproduce Steps to reproduce the behavior:

    1. Run the default action configuration
    jobs:
      compliance:
        name: Compliance
        runs-on: ubuntu-latest
        steps:
        - name: Advanced Security Compliance Action
          uses: GeekMasher/[email protected]
    

    Expected behavior Dependabot violations should be 0.

    Screenshots If applicable, add screenshots to help explain your problem. Screenshot 2021-10-23 at 15 09 13

    Additional context The compliance job is run as a reusable workflow from another repository.

    opened by leostolyarov 4
  • `policy-branch` argument does not work as expected

    `policy-branch` argument does not work as expected

    Describe the bug Action parameter policy-branch is not working as intended. No matter what value is set, it seems to be always using the default branch.

    To Reproduce Setup action with the following params:

    security-compliance:
        runs-on: ubuntu-latest
        needs:
          - codeql
        steps:
          - name: Advance Security Compliance Action
            uses: GeekMasher/[email protected]
            with:
              token: ${{ secrets.GITHUB_PERSONAL_TOKEN }}
              policy: myTestRepo/github-actions
              policy-path: security/policies/default.yml
              policy-branch: security
    

    Expected behavior Action should checkout the branch defined policy-branch

    Screenshots image

    Desktop (please complete the following information): N/A

    Smartphone (please complete the following information): N/A

    Additional context none

    opened by jlouros 4
  • GHAS Compliance Action Default Branch Limitation

    GHAS Compliance Action Default Branch Limitation

    Description

    Limitation identified using Code Scanning and Secret Scanning checks, they are only supported on the default branch. We had hoped these checks could be performed on branch pushes and PRs to catch alerts before they are propagated to the default branch but that functionality does not seem to be supported.

    Propose Solution

    Working with this action we like what we see. We are very interested in this concept and the ability to push security checks farther left in the development process. Proposed solution is to modify this action to work on any branch, not just the default branch, so checks catch alerts on branch pushes and PRs before they are propagated to the default branch.

    enhancement 
    opened by HaleenUptain 3
  • GitHub Enterprise seems to not support ...

    GitHub Enterprise seems to not support ...

    Describe the bug We have updated to the v1.6.3.
    This newer version gives the following error "message": "Field 'dependencyGraphManifests' doesn't exist on type 'Repository'"

    We used the following command line options to disable licensing ( --disable-dependency-licensing --disable-dependencies) and got the same error.

    We grabbed the GraphQL GRAPHQL_DEPENDENCY_INFO from dependency.py and got the same error calling the GraphQL API directly.

    We compared the GitHub Cloud API (https://docs.github.com/en/graphql/overview/schema-previews) with the GitHut Enterprise API (https://docs.github.com/en/[email protected]/graphql/overview/schema-previews).

    GitHub Cloud API has a section called 'Access to a repositories dependency graph preview'. GitHub Enterprise API does NOT have this section.

    Are we correct in assuming this functionality has not been released for GitHub Enterprise yet?

    Is this functionality required for dependabot policy functionality? If it is, which GitHub Enterprise version will support 'Access to a repositories dependency graph preview'?

    To Reproduce Steps to reproduce the behavior:

    1. Run action with dependabot enabled on GitHub Enterprise @3.6.2

    Expected behavior Dependabot policy functionality works as it already does on GitHub Cloud

    bug 
    opened by midwestKC-coder 3
  • Documentation - Using GitHub App with Action

    Documentation - Using GitHub App with Action

    Description

    We need some introductional docs on how to setup and use this Action using a GitHub App.

    Related:

    • #50
      • #51

    +cc @4bg0P

    Propose Solution

    documentation 
    opened by GeekMasher 3
  • License Scanning and Policy : manage unknown license with local file

    License Scanning and Policy : manage unknown license with local file

    Dependabot sometimes fails to get the license information as it is not well documented in a repository for example:

    • https://github.com/pugjs/pug
    • https://github.com/jrburke/amdefine

    The idea would be to:

    • each time we do a test and the licence is unknown:
      • log an issue/contribution in the source repository to allow Dependabot to recognize the license
      • add an entry in a this Action project that will be the list of project/url without license
      • use the information in the policy management with clear information about the fact that it is coming from local scann
    enhancement 
    opened by tgrall 3
  • Change

    Change "conditions" for a more meaningful name

    Description

    As a noob I find confusing the term "conditions" because I don't know if it is a condition to fail or to pass.

    Propose Solution

    Instead of "ignore" and "conditions", can we find something that clearly states what will happen like allow/disallow or similar? I understand this will cause a compatibility issue with existing license policies, but you could warn that there will be a breaking change during a time window to allow everyone to change it.

    @romanoroth, @Padi-owasp

    enhancement 
    opened by jmservera 2
  • Dependabot not supporting GitHub Enterprise

    Dependabot not supporting GitHub Enterprise

    Describe the bug The change to support GitHub enterprise missed changing dependabot.py. It is still using direct GitHub cloud reference: instance = "https://api.github.com/graphql"

    To Reproduce Steps to reproduce the behavior:

    1. Code inspection dependabot.py Line 80 - instance = "https://api.github.com/graphql"

    Expected behavior Dependabot should use the GitHub enterprise URL and not the GitHub Cloud URL

    This change was missed with the merge (https://github.com/GeekMasher/advanced-security-compliance/pull/31) that added support for GitHub Enterprise.

    bug 
    opened by midwestKC-coder 2
  • Deprecation Notice

    Deprecation Notice

    This repository has been moved to a new policy-as-code repository.

    Please migrate all workflows to using the new repository as this repository is no longer receiving updates.

    opened by GeekMasher 0
Releases(v1.7.0)
Owner
Mathew Payne
Security guy with developer tendencies
Mathew Payne
Fast subdomain scanner, Takes arguments from a Json file ("args.json") and outputs the subdomains.

Fast subdomain scanner, Takes arguments from a Json file ("args.json") and outputs the subdomains. File Structure core/ colors.py db/ wordlist.txt REA

whoami security 4 Jul 02, 2022
Automatically fetch, measure, and merge subscription links on the network, use Github Action

Free Node Merge Introduction Modified from alanbobs999/TopFreeProxies It measures the speed of free nodes on the network and import the stable and hig

52 Jul 16, 2022
GitGuardian Shield: protect your secrets with GitGuardian

Detect secret in source code, scan your repo for leaks. Find secrets with GitGuardian and prevent leaked credentials. GitGuardian is an automated secrets detection & remediation service.

GitGuardian 1.2k Dec 27, 2022
DCSync - DCSync Attack from Outside using Impacket

Adding DCSync Permissions Mostly copypasta from https://github.com/tothi/rbcd-at

n00py 77 Dec 16, 2022
Tool-X is a kali linux hacking Tool installer.

Tool-X is a kali linux hacking Tool installer. Tool-X developed for termux and other Linux based systems. using Tool-X you can install almost 370+ hacking tools in termux app and other linux based di

Rajkumar Dusad 4.2k May 29, 2022
A kAFL based hypervisor fuzzer which fully supports nested VMs

hAFL2 hAFL2 is a kAFL-based hypervisor fuzzer. It is the first open-source fuzzer which is able to target hypervisors natively (including Hyper-V), as

SafeBreach Labs 115 Dec 07, 2022
Open source vulnerability DB and triage service.

OSV - Open Source Vulnerabilities OSV is a vulnerability database and triage infrastructure for open source projects aimed at helping both open source

Google 893 Jan 04, 2023
Exploiting CVE-2021-42278 and CVE-2021-42287

noPac Exploiting CVE-2021-42278 and CVE-2021-42287 原项目noPac在实现上可能有点问题,导致在本地没有打通,于是参考sam-the-admin项目进行修改。 使用 pip3 install -r requirements.txt # GetShel

W4ter 2 Jun 23, 2022
For educational purposes only. (Uzbek Edition)

DISCLAIMER 💣 Ushbu skriptdagi materiallar bilan bog'liq har qanday xatti-harakatlar faqat sizning javobgarligingizdir. Ushbu skriptdagi ma'lumotlarda

Husniddin Murodov 1 Feb 12, 2022
Xteam All in one Instagram,Android,phishing osint and wifi hacking tool available

Xteam All in one Instagram,Android,phishing osint and wifi hacking tool available

xploits tech 283 Dec 29, 2022
TOOLS CRACK FACEBOOK

Installation $ pkg update && pkg upgrade $ pkg install python2 $ pkg install git $ git clone https://github.com/Mark-Zuck/zafi $ cd zafi $ pip2 instal

Romi Afrizal 50 Dec 26, 2022
A (completely native) python3 wifi brute-force attack using the 100k most common passwords (2021)

wifi-bf [LINUX ONLY] A (completely native) python3 wifi brute-force attack using the 100k most common passwords (2021) This script is purely for educa

Finn Lancaster 20 Nov 12, 2022
Separation of Mainlobes and Sidelobes in the Ultrasound Image Based on the Spatial Covariance (MIST) and Aperture-Domain Spectrum of Received Signals

Separation of Mainlobes and Sidelobes in the Ultrasound Image Based on the Spatial Covariance (MIST) and Aperture-Domain Spectrum of Received Signals

Rehman Ali 3 Jan 03, 2023
Caretaker 2 Jun 06, 2022
Multi-Process Vulnerability Tool

Multi-Process Vulnerability Tool

Baris Dincer 1 Dec 22, 2021
Simplify getting and using cookies from the browser to use in Python.

CookieCache Simplify getting and using cookies from the browser to use in Python. NOTE: All the logic to interface with the browsers is done by the Br

pat_h/to/file 2 May 06, 2022
Sqli-Scanner is a python3 script written to scan websites for SQL injection vulnerabilities

Sqli-Scanner is a python3 script written to scan websites for SQL injection vulnerabilities Features 1 Scan one website 2 Scan multiple websites Insta

Anontemitayo 9 Dec 30, 2022
A TCP Backdoor made in python

Tracey-Backdoor A Reverse Shell Backdoor made in python OOP. It supposed to work in Windows and Linux OS Functions: Reverse Connection Send Reverse TC

13 Oct 15, 2022
Jolokia Exploitation Toolkit (JET) helps exploitation of exposed jolokia endpoints.

jolokia-exploitation-toolkit Jolokia Exploitation Toolkit (JET) helps exploitation of exposed jolokia endpoints. Core concept Jolokia is a protocol br

Laluka 194 Jan 01, 2023
This is a repository filled with scripts that were made with Python, and designed to exploit computer systems.

PYTHON-EXPLOITATION This is a repository filled with scripts that were made with Python, and designed to exploit computer systems. Networking tcp_clin

Nathan Galindo 1 Oct 30, 2021