Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/build workflow #19

Merged
merged 12 commits into from
Aug 17, 2023
28 changes: 27 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:

permissions:
contents: read
id-token: write

jobs:
build:
Expand All @@ -31,4 +32,29 @@ jobs:
- name: Build with hachling
run: |
python -m build
ls
ls
- name: Install cosign
uses: sigstore/[email protected]
with:
inputs: dist/scsctl-0.0.3-py3-none-any.whl
- name: Sign with sigstore using GitHub App credentials
run: |
sigstore sign --overwrite dist/scsctl-0.0.3-py3-none-any.whl
- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: dist
path: |
dist
- name: Copy dist/scsctl-0.0.3.tar.gz dist/scsctl-0.0.3-py3-none-any.whl to release directory
run: |
mkdir -p release
cp dist/scsctl-0.0.3.tar.gz release/scsctl-0.0.3.tar.gz
cp dist/scsctl-0.0.3-py3-none-any.whl release/scsctl-0.0.3-py3-none-any.whl

- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
packages-dir: release
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ build-backend = "hatchling.build"

[project]
name = "scsctl"
version = "0.0.1"
version = "0.0.3"
authors = [{name="Jegath S", email="[email protected]" }]
description = "Tool for automating Vulnerability Risk Management and Software Supply Chain Security Measures"
readme = "README.md"
dependencies = ['click==8.1.3', 'clickhouse-driver==0.2.6', 'numpy==1.25.0', 'requests==2.31.0','questionary==1.10.0','tabulate==0.9.0']
dependencies = ['click==8.1.3', 'clickhouse-driver==0.2.6', 'numpy==1.25.0', 'requests==2.31.0','questionary==1.10.0','tabulate==0.9.0','kubernetes==27.2.0']
requires-python = ">=3.9"

[project.scripts]
Expand Down
6 changes: 3 additions & 3 deletions src/scsctl/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,14 @@ def scan(
if(non_interactive):
click.echo("Sbom report")
click.echo("===========")
print_sbom_report(sbom_report)
print_sbom_report(sbom_report = sbom_report,is_non_interactive = True)
click.echo("Pyroscope detected packages")
click.echo("===========================")
print_pyroscope_packages(pyroscope_data)
print_pyroscope_packages(pyroscope_package_names = pyroscope_data,is_non_interactive = True)
if falco_enabled:
click.echo("Falco detected packages")
click.echo("=======================")
print_falco_packages(falco_found_extra_packages)
print_falco_packages(falco_package_names = falco_found_extra_packages,is_non_interactive = True)
click.echo("Final Report")
click.echo("=============")
click.echo(final_report)
Expand Down
10 changes: 8 additions & 2 deletions src/scsctl/helper/falco.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,22 @@ def compare_and_find_extra_packages_using_falco(falco_package_names, sbom_packag
return extra_packages


def print_falco_packages(falco_package_names):
def print_falco_packages(falco_package_names,is_non_interactive=False):
headers = ["Packages"]
data = []
for item in falco_package_names:
data.append([item])

width = [100]

if is_non_interactive:
print(tabulate(data, headers=headers, tablefmt="grid",maxcolwidths=width, showindex=list(range(1, len(data) + 1))))
return


chunk_size = 200
index = 0

width = [100]

while index < len(data):
table = tabulate(
Expand Down
8 changes: 6 additions & 2 deletions src/scsctl/helper/pyroscope.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def get_pyroscope_data(app_details: AppDetails):
return [], False


def print_pyroscope_packages(pyroscope_package_names):
def print_pyroscope_packages(pyroscope_package_names,is_non_interactive = False):
if "total" in pyroscope_package_names:
pyroscope_package_names.remove("total")
if "other" in pyroscope_package_names:
Expand All @@ -33,11 +33,15 @@ def print_pyroscope_packages(pyroscope_package_names):
data = []
for item in pyroscope_package_names:
data.append([item])

width = [100]
if is_non_interactive:
print(tabulate(data, headers=headers, tablefmt="grid",maxcolwidths=width, showindex=list(range(1, len(data) + 1))))
return

chunk_size = 200
index = 0

width = [100]

while index < len(data):
table = tabulate(
Expand Down
7 changes: 5 additions & 2 deletions src/scsctl/helper/trivy.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def get_sbom_report(app_details: AppDetails):
return "", False


def print_sbom_report(sbom_report):
def print_sbom_report(sbom_report,is_non_interactive=False):
sbom_report = json.loads(sbom_report)
sbom_report = sbom_report["Results"]
sbom_report = [item["Vulnerabilities"] for item in sbom_report if item["Class"] != "lang-pkgs"][0]
Expand All @@ -71,7 +71,10 @@ def print_sbom_report(sbom_report):

# Change width of the columns (First width is for the index column)
width = [10, 20, 20, 20, 10, 10, 80]
# print(data)

if is_non_interactive:
print(tabulate(data, headers=headers, tablefmt="grid",maxcolwidths=width, showindex=list(range(1, len(data) + 1))))
return

while index < len(data):
table = tabulate(
Expand Down
Loading