ditch travis and add github action

This commit is contained in:
Ali-Razmjoo 2021-01-28 14:43:58 +01:00
parent 6b266fd1c0
commit b25129f180
7 changed files with 66 additions and 124 deletions

62
.github/workflows/CI.yml vendored Normal file
View File

@ -0,0 +1,62 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: CI
on:
push:
branches:
- master
- development
paths:
- '**.py'
pull_request:
branches:
- master
- development
paths:
- '**.py'
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8] # python version is defined in docker
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Upgrade pip
run: python -m pip install --upgrade pip
- name: Install development dependencies
run: sudo pip install -r requirements-dev.txt
- name: lint check with flake8
run: flake8 --extend-exclude '*.txt,*.js,*.md,*.html' --count --select=E9,F63,F7,F82 --show-source
- name: Build the code with docker
run: docker build . -t nettacker
- name: Help Menu
run: docker run -v $(pwd):/usr/src/owaspnettacker --rm nettacker python nettacker.py --help
- name: Help Menu in Persian
run: docker run -v $(pwd):/usr/src/owaspnettacker --rm nettacker python nettacker.py --help -L fa
- name: Test all modules command + check if it's finish successfully + without graph
run: docker run -v $(pwd):/usr/src/owaspnettacker --rm -i nettacker python nettacker.py -i 127.0.0.1 -u user1,user2 -p pass1,pass2 -m all -g 21,25,80,443 -t 10000000 -T 0.1 -v 5 --method-args "subdomain_scan_time_limit_seconds=5"
- name: Test all modules command + check if it's finish successfully + with graph
run: docker run -v $(pwd):/usr/src/owaspnettacker --rm -i nettacker python nettacker.py -i 127.0.0.1 -u user1,user2 -p pass1,pass2 -m all -g 21,25,80,443 -t 10000000 -T 0.1 --graph d3_tree_v2_graph --method-args "subdomain_scan_time_limit_seconds=5" -v 5
- name: Test all modules command + check if it's finish successfully + without graph + Persian
run: docker run -v $(pwd):/usr/src/owaspnettacker --rm -i nettacker python nettacker.py -i 127.0.0.1 -L fa -u user1,user2 -p pass1,pass2 -m all -g 21,25,80,443 -t 10000000 -T 0.1 -v 5 --method-args "subdomain_scan_time_limit_seconds=5"
- name: Test all modules command + check if it's finish successfully + with graph + Persian
run: docker run -v $(pwd):/usr/src/owaspnettacker --rm -i nettacker python nettacker.py -i 127.0.0.1 -L fa -u user1,user2 -p pass1,pass2 -m all -g 21,25,80,443 -t 10000000 -T 0.1 --graph d3_tree_v2_graph --method-args "subdomain_scan_time_limit_seconds=5" -v 5

View File

@ -1,35 +0,0 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Python Flake8 Checks
on:
push:
branches: [ master ]
paths:
- '**.py'
pull_request:
branches: [ master ]
paths:
- '**.py'
jobs:
build:
runs-on: ubuntu-latest
strategy:
# max-parallel: 2
matrix:
python-version: [3.8] # Lint check on one python version is enough
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Lint with flake8
run: |
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
# stop the build if there are Python syntax errors or undefined names
flake8 --extend-exclude '*.txt,*.js,*.md,*.html' --count --select=E9,F63,F7,F82 --show-source

View File

@ -1,45 +0,0 @@
# Select language
language: python
# Select python version
python:
# - "2.6" paramiko not supported
- "2.7"
# - "3.2" texttable is not supporting this version!
# - "3.3" paramiko not supported
# - "3.4" error due to canari now requiring 3.5: https://travis-ci.org/zdresearch/OWASP-Nettacker/jobs/624877324#L282
- "3.5"
- "3.6"
- "3.6-dev"
# - "3.7-dev" error at the moment: https://travis-ci.org/viraintel/OWASP-Nettacker/jobs/332849350
# - "nightly" error at the moment: https://travis-ci.org/viraintel/OWASP-Nettacker/jobs/332849351
# Select OS
os:
- "linux"
# Install requirements
install:
- "pip list"
- "pip install --upgrade wheel"
- "pip install --upgrade setuptools codacy-coverage coverage"
- "pip install --upgrade flake8"
- "pip install --upgrade -r requirements.txt"
# scapy has different name in python 2.x and 3.x
- if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then pip install scapy; else pip install scapy-python3; fi
# Run
script:
- "python scripts/__travis_test__.py"
- if [[ ${#CODACY_PROJECT_TOKEN} == 32 ]];
then
coverage erase &&
coverage run nettacker.py -i 127.0.0.1 -m all -t 1000 &&
coverage report -m &&
coverage xml &&
sed -i.bak '/<source><\/source>/d' coverage.xml &&
python-codacy-coverage -r coverage.xml;
else
echo "skip code coverage section";
fi;
- "flake8 . --select=E9,F7,F82"

View File

@ -3,5 +3,7 @@ RUN apt update
RUN apt install -y openssl libffi-dev musl-dev make gcc git curl librtmp* libxml2-dev libxslt-dev
WORKDIR /usr/src/owaspnettacker
COPY . .
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
RUN pip install -r requirements-dev.txt
CMD [ "python", "./nettacker.py" ]

View File

@ -1,11 +1,6 @@
OWASP Nettacker
=========
[![Build Status Travic CI](https://travis-ci.org/zdresearch/OWASP-Nettacker.svg?branch=master)](https://travis-ci.org/zdresearch/OWASP-Nettacker)
[![Donate US](https://img.shields.io/badge/Donate-OWASP-green.svg)](https://owasp.org/donate/?reponame=www-project-nettacker&title=OWASP+Nettacker)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/04ca57d1b996435d8a42c767add84859)](https://www.codacy.com/app/zdresearch/OWASP-Nettacker?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=zdresearch/OWASP-Nettacker&amp;utm_campaign=Badge_Grade)
[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/04ca57d1b996435d8a42c767add84859)](https://www.codacy.com/app/zdresearch/OWASP-Nettacker?utm_source=github.com&utm_medium=referral&utm_content=zdresearch/OWASP-Nettacker&utm_campaign=Badge_Coverage)
[![Python 2.x](https://img.shields.io/badge/python-2.x-blue.svg)](https://travis-ci.org/zdresearch/OWASP-Nettacker)
[![Python 3.x](https://img.shields.io/badge/python-3.x-blue.svg)](https://travis-ci.org/zdresearch/OWASP-Nettacker)
[Build Status](https://github.com/OWASP/Nettacker/workflows/CI/badge.svg?branch=master)
[![Apache License](https://img.shields.io/badge/License-Apache%20v2-green.svg)](https://github.com/OWASP/Nettacker/blob/master/LICENSE)
[![Twitter](https://img.shields.io/badge/Twitter-@iotscan-blue.svg)](https://twitter.com/iotscan)
![GitHub contributors](https://img.shields.io/github/contributors/zdresearch/OWASP-Nettacker)

View File

@ -1,2 +1 @@
flake8==3.8.3
pytest==6.2.2
flake8==3.8.3

View File

@ -1,36 +0,0 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
# Test help menu command
os.system("time python nettacker.py --help")
os.system("time python nettacker.py --help -L fa")
# Test show version command
os.system("time python nettacker.py --version")
# Test all modules command + check if it's finish successfully + without graph
if os.system("time python nettacker.py -i 127.0.0.1 -u user1,user2 -p "
"pass1,pass2 -m all -g 21,25,80,443 -t 10000000 -T 0.1 -v 5 --method-args \"subdomain_scan_time_limit_"
"seconds=5\"") != 0:
sys.exit(1)
# Test all modules command + check if it's finish successfully + with graph
if os.system("time python nettacker.py -i 127.0.0.1 -u user1,user2 -p "
"pass1,pass2 -m all -g 21,25,80,443 -t 10000000 -T 0.1 --graph d3_tree_v2_graph"
" --method-args \"subdomain_scan_time_limit_seconds=5\" -v 5 ") != 0:
sys.exit(1)
# Test all modules command + check if it's finish successfully + without
# graph + Farsi
if os.system("time python nettacker.py -i 127.0.0.1 -u user1,user2 -p "
"pass1,pass2 -m all -g 21,25,80,443 -t 10000000 -T 0.1 -L fa "
"-v 5 --method-args \"subdomain_scan_time_limit_seconds=5\"") != 0:
sys.exit(1)
# Test all modules command + check if it's finish successfully + with
# graph + Farsi
if os.system("time python nettacker.py -i 127.0.0.1 -u user1,user2 -p "
"pass1,pass2 -m all -g 21,25,80,443 -t 10000000 -T 0.1 -L fa --graph d3_tree_v2_graph"
" -v 5 --method-args \"subdomain_scan_time_limit_seconds=5\"") != 0:
sys.exit(1)
# Test all modules for second time (testing cache) command
os.system("time python nettacker.py -i 127.0.0.1 -u user1,user2 -p pass1,pass2 -m all -g 21,25,80,443 -t 10000000"
" -T 0.1 -v 5 --method-args \"subdomain_scan_time_limit_seconds=5\"")