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

PA-11335 Rewrite of Dast wrapper on typescript/auth cleanup #75

Merged
merged 26 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
cb429b4
PA-11335 Rewrite of Dast wrapper on typescript/auth cleanup
SOOS-JAlvarez Nov 3, 2023
112c32b
partial code review
SOOS-JAlvarez Nov 6, 2023
836e789
added zap command generator back with uppercase
SOOS-JAlvarez Nov 6, 2023
e65ade0
switch to barrel pattern for utilities, rework constants
SOOS-JAlvarez Nov 6, 2023
3efc52c
rename of hook files
SOOS-JAlvarez Nov 6, 2023
d9e7dd1
finish sarif, update scan only when it's not done
SOOS-JAlvarez Nov 6, 2023
d56b858
Added onfailure behaviour
SOOS-JAlvarez Nov 6, 2023
38c6796
code review
SOOS-JAlvarez Nov 6, 2023
8d78a81
improve logging inside hook
SOOS-JAlvarez Nov 6, 2023
9f61924
logging as close as possible to python one
SOOS-JAlvarez Nov 6, 2023
883f438
wire up other options, fix zapOptions
SOOS-JAlvarez Nov 6, 2023
53a6f3e
update param descriptions and readme
SOOS-JAlvarez Nov 6, 2023
f42ea19
alphabetically sort params on readme
SOOS-JAlvarez Nov 6, 2023
47a06b4
update login_from_token_endpoint
SOOS-JAlvarez Nov 7, 2023
2e3de61
obfuscate sensitive data on param print
SOOS-JAlvarez Nov 7, 2023
62ca1fb
added action for test
SOOS-JAlvarez Nov 7, 2023
d2a1551
fix test, added typescript to codeql
SOOS-JAlvarez Nov 7, 2023
ff8ca3b
removed stuff without reference from the hook
SOOS-JAlvarez Nov 7, 2023
601dfba
rename python files to snake_case
SOOS-JAlvarez Nov 7, 2023
4cc816c
npm outdated on check, removed tests, more unused utils
SOOS-JAlvarez Nov 7, 2023
befa033
access token instead of token_type
SOOS-JAlvarez Nov 7, 2023
5427d72
upgrade actions
SOOS-JAlvarez Nov 7, 2023
3372bbd
dump version txt use package.json version from now onwards
SOOS-JAlvarez Nov 7, 2023
7fda5ed
remove zaproxy dependency
SOOS-JAlvarez Nov 7, 2023
ec9df37
code review
SOOS-JAlvarez Nov 7, 2023
266181d
npm outdated fix
SOOS-JAlvarez Nov 7, 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
230 changes: 2 additions & 228 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,228 +1,2 @@
.DS_Store

### Python template
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# 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
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

.idea

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### VisualStudioCode template
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace

# Local History for Visual Studio Code
.history/

/node_modules
/dist
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parser": "typescript",
"printWidth": 100,
"quoteProps": "consistent",
"endOfLine": "auto"
}
19 changes: 19 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"editor.tabSize": 2,
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"prettier.configPath": "./.prettierrc",
"cSpell.words": [
"apiscan",
"DAST",
"fullscan",
"httpsender",
"Levelkey",
"nargs",
"SARIF",
"SOOS",
"SOOSDAST",
"SPIDERED"
],
"sarif-viewer.connectToGithubCodeScanning": "off",
}
72 changes: 36 additions & 36 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,39 @@
# if the image or tag changes, make sure to update the scan structure tool name and version
FROM soosio/zap2docker-soos as base
SOOS-JAlvarez marked this conversation as resolved.
Show resolved Hide resolved

USER root

COPY ./main.py ./requirements.txt ./VERSION.txt ./
COPY ./helpers helpers/
COPY ./hooks hooks/
COPY ./model model/
COPY ./scripts/httpsender /home/zap/.ZAP/scripts/scripts/httpsender/
RUN chmod 777 /home/zap/.ZAP/scripts/scripts/httpsender/
# Install nodejs version based on NODE_MAJOR
ENV NODE_MAJOR 18
RUN apt-get update
RUN apt-get install -y ca-certificates curl gnupg
RUN mkdir -p /etc/apt/keyrings
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_${NODE_MAJOR}.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
RUN apt-get update
RUN apt-get install -y nodejs

COPY ./reports/traditional-json /zap/reports/traditional-json
COPY ./reports/traditional-json-headers /zap/reports/traditional-json-headers
RUN chmod -R 444 /zap/reports/traditional-json
RUN chmod -R 444 /zap/reports/traditional-json-headers
COPY ./src/ ./src/
COPY ./tsconfig.json ./
COPY ./package.json ./

RUN pip3 install -r requirements.txt && mkdir /zap/wrk && cd /opt \
&& wget -qO- -O geckodriver.tar.gz https://github.com/mozilla/geckodriver/releases/download/v0.30.0/geckodriver-v0.30.0-linux64.tar.gz \
&& tar -xvzf geckodriver.tar.gz \
&& chmod +x geckodriver \
&& ln -s /opt/geckodriver /usr/bin/geckodriver \
&& export PATH=$PATH:/usr/bin/geckodriver
RUN pip3 install -r ./src/hooks/requirements.txt

# Set up the Chrome PPA
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list
RUN mkdir /zap/wrk && cd /opt \
&& wget -qO- -O geckodriver.tar.gz https://github.com/mozilla/geckodriver/releases/download/v0.30.0/geckodriver-v0.30.0-linux64.tar.gz \
&& tar -xvzf geckodriver.tar.gz \
&& chmod +x geckodriver \
&& ln -s /opt/geckodriver /usr/bin/geckodriver \
&& export PATH=$PATH:/usr/bin/geckodriver

RUN cd /zap/plugin && \
rm -rf ascanrules-* && wget https://github.com/zaproxy/zap-extensions/releases/download/ascanrules-v49/ascanrules-release-49.zap && \
rm -rf ascanrulesBeta-* && wget https://github.com/zaproxy/zap-extensions/releases/download/ascanrulesBeta-v44/ascanrulesBeta-beta-44.zap && \
rm -rf commonlib-* && wget https://github.com/zaproxy/zap-extensions/releases/download/commonlib-v1.12.0/commonlib-release-1.12.0.zap && \
rm -rf network-* && wget https://github.com/zaproxy/zap-extensions/releases/download/network-v0.6.0/network-beta-0.6.0.zap && \
rm -rf oast-* && wget https://github.com/zaproxy/zap-extensions/releases/download/oast-v0.14.0/oast-beta-0.14.0.zap && \
rm -rf pscanrules-* && wget https://github.com/zaproxy/zap-extensions/releases/download/pscanrules-v44/pscanrules-release-44.zap && \
rm -rf pscanrulesBeta-* && wget https://github.com/zaproxy/zap-extensions/releases/download/pscanrulesBeta-v31/pscanrulesBeta-beta-31.zap && \
chown -R zap:zap /zap

# Set up Chrome version to be used
ARG CHROME_VERSION="114.0.5735.133-1"
Expand All @@ -47,22 +56,13 @@ RUN unzip $CHROMEDRIVER_DIR/chromedriver* -d $CHROMEDRIVER_DIR
# Put Chromedriver into the PATH
ENV PATH $CHROMEDRIVER_DIR:$PATH

RUN cd /zap/plugin && \
rm -rf ascanrules-* && wget https://github.com/zaproxy/zap-extensions/releases/download/ascanrules-v49/ascanrules-release-49.zap && \
rm -rf ascanrulesBeta-* && wget https://github.com/zaproxy/zap-extensions/releases/download/ascanrulesBeta-v44/ascanrulesBeta-beta-44.zap && \
rm -rf commonlib-* && wget https://github.com/zaproxy/zap-extensions/releases/download/commonlib-v1.12.0/commonlib-release-1.12.0.zap && \
rm -rf network-* && wget https://github.com/zaproxy/zap-extensions/releases/download/network-v0.6.0/network-beta-0.6.0.zap && \
rm -rf oast-* && wget https://github.com/zaproxy/zap-extensions/releases/download/oast-v0.14.0/oast-beta-0.14.0.zap && \
rm -rf pscanrules-* && wget https://github.com/zaproxy/zap-extensions/releases/download/pscanrules-v44/pscanrules-release-44.zap && \
rm -rf pscanrulesBeta-* && wget https://github.com/zaproxy/zap-extensions/releases/download/pscanrulesBeta-v31/pscanrulesBeta-beta-31.zap && \
chown -R zap:zap /zap


FROM base as test
COPY ./tests tests/
COPY ./src/reports/traditional-json /zap/reports/traditional-json
COPY ./src/reports/traditional-json-headers /zap/reports/traditional-json-headers
RUN chmod -R 444 /zap/reports/traditional-json
RUN chmod -R 444 /zap/reports/traditional-json-headers

ENTRYPOINT ["python3", "-m", "unittest", "tests/tests.py"]
RUN npm install

FROM base as production
RUN npm run build

ENTRYPOINT ["python3", "main.py"]
ENTRYPOINT ["node", "dist/index.js"]
15 changes: 0 additions & 15 deletions config-example.yml

This file was deleted.

Empty file removed helpers/__init__.py
Empty file.
Loading