Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
0dd09c9
1. Added Trivy to the pipeline in plugins.py
pieterge Dec 22, 2022
a89c692
1. Add path to CLI arguments
pieterge Dec 22, 2022
031a1bf
1. Add path to CLI arguments
pieterge Dec 22, 2022
8451bc9
1. Added arguments in argparse for accepting GitHub information
pieterge Dec 27, 2022
c78b94a
1. Added input validation for directory for both absolute and relativ…
pieterge Dec 27, 2022
821c41c
1. Added function in controlflow for github annotations
pieterge Dec 27, 2022
1f8955d
Black Reformat
pieterge Dec 27, 2022
bbe4f44
1. Added scanning dir to bandig, safety and dodgy
pieterge Dec 27, 2022
f4e5615
1. Improved export from flake8
pieterge Dec 27, 2022
1837260
1. Resolved issues with how trivy return paths for file scanning
pieterge Dec 27, 2022
9535dbd
1. Refactored path handling for simplified logic
pieterge Dec 27, 2022
ce62deb
Removed bug where it overrides the trivy results with an empty list.
pieterge Dec 27, 2022
0d5ba6f
Cleaning up multiple newlines to single new line
pieterge Dec 27, 2022
f791ba5
Added scanning for evidence in the trivy implementation
pieterge Dec 27, 2022
ccceea0
Refactor the scanning function to return the linenrs too. This suppor…
pieterge Dec 27, 2022
afa166d
1. Reformat Black
pieterge Dec 27, 2022
4cf3555
Added Black to the list and prettified the printout. There is no mean…
pieterge Dec 27, 2022
359f79e
Refactor path handling, bugfix.
pieterge Dec 27, 2022
2b40f9b
Cleaning up and adding docstrings
pieterge Dec 27, 2022
3abc2fe
1. Refactored code for ReStructured Text Docstrings
pieterge Dec 28, 2022
63534e1
1. Cleaned up the main sphinx page index.rst
pieterge Dec 28, 2022
e06011a
1. Dynamically loads the License.md into the sphinx documentation
pieterge Dec 28, 2022
c8fd018
Typo..
pieterge Dec 28, 2022
3c9d01e
managing dependencies, removing optional dependencies.
pieterge Dec 29, 2022
fe83297
1. tweaking dependencies and narrowing search path for performance.
pieterge Dec 29, 2022
98da466
Merge pull request #1 from Keelvar/feature/ENG-4069_modify_defaults
pieterge Dec 29, 2022
73d3676
Create main.yml
pieterge Dec 29, 2022
816dcdc
Update main.yml
pieterge Dec 29, 2022
7324e65
1. tweaking dependencies and narrowing search path for performance.
pieterge Dec 29, 2022
31b96ba
Merge pull request #2 from Keelvar/feature/ENG-4069_modify_defaults
pieterge Dec 29, 2022
1f51ba2
tweaking CI
pieterge Dec 29, 2022
50fe2ec
tweaking CI
pieterge Dec 29, 2022
d631ac8
Merge remote-tracking branch 'origin/master'
pieterge Dec 29, 2022
2189864
Sphinx GitHub Action
pieterge Dec 29, 2022
696b824
Adding requirements.txt for documentation to enable CI
pieterge Dec 29, 2022
faccc9b
Adding PyGitHub for Sphinx for type hinting to the requirements.txt o…
pieterge Dec 29, 2022
8d1814d
Sphinx Action: Writing the resulting html files to repo.
pieterge Dec 29, 2022
4d887ab
Testing directories
pieterge Dec 29, 2022
cd2b3cc
Testing directories
pieterge Dec 29, 2022
fcc4909
Resolving path issues
pieterge Dec 29, 2022
c0594eb
Resolving path issues
pieterge Dec 29, 2022
3a8ea0c
Resolving path issues
pieterge Dec 29, 2022
b301840
isolating the dependencies of poetry
pieterge Dec 29, 2022
b8ddc71
Sloppy typo
pieterge Dec 29, 2022
65a6941
Another sloppy typo
pieterge Dec 29, 2022
5badba9
Adding lock file
pieterge Dec 29, 2022
e4aa29a
Updated pyproject.toml and poetry.lock to accommodate for lower versi…
pieterge Dec 29, 2022
594af3c
Modularizing pyproject.toml with a docs and scanners flag.
pieterge Jan 2, 2023
80667cd
Merge pull request #3 from FHPythonUtils/master
pieterge Jan 2, 2023
3d0c4b0
Adding isort and mypy to the library. Assuming that isort has no mean…
pieterge Jan 2, 2023
5246537
readding poetry.lock
pieterge Jan 2, 2023
0f61981
1. Updating pyproject.toml and poetry.lock (issues with sphinx depend…
pieterge Jan 2, 2023
718d679
- Renamed dlint to flake8 and removed the DUO options as these are no…
pieterge Feb 2, 2023
971517f
testing annotations in the CI pipeline
pieterge Feb 2, 2023
f903831
testing annotations in the CI pipeline take2
pieterge Feb 6, 2023
d999692
using flags properly
pieterge Feb 6, 2023
7e29e6b
removing \ linebrakes
pieterge Feb 6, 2023
7a46c46
changing path to string and adding templating braces
pieterge Feb 6, 2023
53e79a2
Changing ENV variable GITHUB_REF
pieterge Feb 6, 2023
a806048
Cast scan_path to string
pieterge Feb 6, 2023
33c1289
changing reference to path
pieterge Feb 6, 2023
c71ef01
try again with vanilla period
pieterge Feb 6, 2023
179cdd0
assertion issues, testing..
pieterge Feb 6, 2023
c758405
syntax isues
pieterge Feb 6, 2023
99de051
syntax issues
pieterge Feb 6, 2023
977a87a
testing more explicit dir as argparse is defaulting to None value
pieterge Feb 6, 2023
1319f9b
making a string of dir
pieterge Feb 6, 2023
f4072e8
using env variable
pieterge Feb 6, 2023
f1f1e48
reproducing old example
pieterge Feb 6, 2023
d3f61f7
does this work with everything on the same line?
pieterge Feb 6, 2023
deb4e80
does this work with everything on the same line? adjusting the config…
pieterge Feb 6, 2023
971ccbb
Changing yaml to folded style to support linebraking
pieterge Feb 6, 2023
787f249
removing debug print out and adding findings object to annotation fun…
pieterge Feb 6, 2023
afef9b2
Changing CI to be triggered only in pull request. Duplicated non-comm…
pieterge Feb 6, 2023
6456de1
clean up
pieterge Feb 6, 2023
36b2335
removing whitespaces
pieterge Feb 6, 2023
f19060d
Adding annotations function
RobertoCassino Feb 16, 2023
6a53256
referencing the findings dict
RobertoCassino Feb 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/simplesecurity_pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: simplesecurity_pr

on: pull_request

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: poetry
- name: Install dependencies
run: poetry install --no-root
- name: Install Trivy
run: |
/bin/bash install_trivy.sh
trivy -h
- name: run scans
run: >
poetry run simplesecurity --send_to_git
--github_repository ${{ github.event.repository.name }}
--github_pr_number GITHUB_REF
--github_access_token ${{ secrets.GITHUB_TOKEN }}
--scan_path .
25 changes: 25 additions & 0 deletions .github/workflows/simplesecurity_push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: simplesecurity_push

on: push

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: poetry
- name: Install dependencies
run: poetry install --no-root
- name: Install Trivy
run: |
/bin/bash install_trivy.sh
trivy -h
- name: run scans
run: >
poetry run simplesecurity
--scan_path .
20 changes: 20 additions & 0 deletions .github/workflows/sphinx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: "Docs Check"
on:
- pull_request
- push

jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: ammaraskar/sphinx-action@master
with:
pre-build-command: |
pip install -r docs/requirements.txt
build-command: "sphinx-build -b html . ../build/html"
docs-folder: "docs/source/"
- uses: actions/upload-artifact@v1
with:
name: DocumentationHTML
path: docs/build/html/
8 changes: 1 addition & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@

README.rst

# DepHell stuff
poetry.lock

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down Expand Up @@ -96,7 +90,7 @@ ipython_config.py
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# having no cross-platform support.rst, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

Expand Down
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
12 changes: 12 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
docutils==0.17
sphinx-autodoc-typehints==1.19.5
sphinx-mdinclude==0.5.3
sphinx-rtd-theme==1.1.1
sphinx==5.3.0
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
pygithub >= 1.57
4 changes: 4 additions & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Changelog
=========

See the `Changelog </CHANGELOG.md>`_ for more information.
7 changes: 7 additions & 0 deletions docs/source/codeOfConduct.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Code of Conduct
===============

Online communities include people from many backgrounds. The *Project*
contributors are committed to providing a friendly, safe and welcoming
environment for all. Please see the
`Code of Conduct <https://github.com/FHPythonUtils/.github/blob/master/CODE_OF_CONDUCT.md>`_ for more information.
77 changes: 77 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys

sys.path.insert(0, os.path.abspath("../.."))


# -- Project information -----------------------------------------------------

project = "SimpleSecurity"
copyright = "2022, FredHappyface, Pieter Geelen"
author = "FredHappyface, Pieter Geelen"

# The full version, including alpha/beta/rc tags
release = "2023.1.1"


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"sphinx.ext.autodoc",
"sphinx_rtd_theme",
"sphinx_autodoc_typehints",
"sphinx_mdinclude",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "sphinx_rtd_theme"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]

html_theme_options = {
"logo_only": True,
"display_version": False,
"prev_next_buttons_location": "bottom",
"style_external_links": False,
"vcs_pageview_mode": "display_github",
# 'style_nav_header_background': 'blue',
# Toc options
"collapse_navigation": True,
"sticky_navigation": True,
"navigation_depth": 4,
"includehidden": True,
"titles_only": False,
}

html_logo = "../../readme-assets/icons/proj-icon.png"
5 changes: 5 additions & 0 deletions docs/source/contribution.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Contributing
============

Contributions are welcome, please see the
`Contributing Guidelines <https://github.com/FHPythonUtils/.github/blob/master/CONTRIBUTING.md>`_ for more information.
78 changes: 78 additions & 0 deletions docs/source/gettingstarted.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
Getting Started
===============

Install With PIP
----------------
A requirement for using SimpleSecurity is having a version of python 3.x installed.

.. highlight:: bash
.. code-block:: bash

pip install simplesecurity



Head to https://pypi.org/project/SimpleSecurity/ for more info
This program has been written for Python versions 3.7 - 3.10 and has been tested with both 3.7 and
3.10

Run CLI
---------
In order to run the CLI utility, you can run `simplesecurity` in this directory

.. image:: ../../readme-assets/screenshots/sec.svg
:width: 500px
:alt: Screenshot

Options in the CLI tool include:

.. highlight:: bash
.. code-block:: bash

usage: __main__.py [-h] [--format FORMAT] [--plugin PLUGIN] [--file FILE]
[--level LEVEL] [--confidence CONFIDENCE]
[--no-colour] [--high-contrast] [--fast] [--zero]

Combine multiple popular python security tools...

and generate reports or output into different formats.

optional arguments:
-h, --help show this help message and exit
--format FORMAT, -f FORMAT
Output format. One of ansi, json, markdown, csv. default=ansi
--plugin PLUGIN, -p PLUGIN
Plugin to use. One of bandit, safety, dodgy, dlint, semgrep, all, default=all
--file FILE, -o FILE Filename to write to (omit for stdout)
--level LEVEL, -l LEVEL
Minimum level/ severity to show
--confidence CONFIDENCE, -c CONFIDENCE
Minimum confidence to show
--no-colour, -z No ANSI colours
--high-contrast, -Z High contrast colours
--fast, --skip Skip long running jobs. Will omit plugins with long run time (applies to -p all only)
--zero, -0 Return non zero exit code if any security vulnerabilities are found


You can also import this into your own project and use any of the functions
in the DOCS

Configuring Semgrep
-------------------
The configuration of SemGrep is organized with a `yaml` file. A default config is already enclosed in this library. I
you want to specify the config, you can follow the steps below:

1. Clone https://github.com/returntocorp/semgrep-rules
2. cd to `semgrep-rules/python`
3. do

.. highlight:: bash
.. code-block:: bash

cat **/security/**/*.yaml >> semgrep_sec.yaml
cat **/security/*.yaml >> semgrep_sec.yaml


4. Find and replace `rules:` with `` apart from the first instance
5. Reformat with `ctrl+shift+i`
6. replace simplesecurity/semgrep_sec.yaml with the new one
Loading