diff --git a/.github/workflows/scheduled_job.yaml b/.github/workflows/scheduled_job.yaml index e3fdad4..2aa932c 100644 --- a/.github/workflows/scheduled_job.yaml +++ b/.github/workflows/scheduled_job.yaml @@ -5,8 +5,10 @@ on: - cron: "0 12 * * SUN" workflow_dispatch: +env: + REPO_OWNER: ${{ github.repository_owner }} + jobs: - Project-runner: strategy: matrix: @@ -93,7 +95,7 @@ jobs: - name: fetch repo uses: actions/checkout@v3 with: - repository: vandanrohatgi/Seaweed-Reports + repository: ${{ env.REPO_OWNER }}/Seaweed-Reports token: ${{ secrets.GAT }} - name: set env @@ -127,7 +129,7 @@ jobs: - name: fetch repo uses: actions/checkout@v3 with: - repository: vandanrohatgi/Seaweed-Reports + repository: ${{ env.REPO_OWNER }}/Seaweed-Reports token: ${{ secrets.GAT }} - name: set target directory diff --git a/.github/workflows/test_run.yaml b/.github/workflows/test_run.yaml deleted file mode 100644 index 16307a9..0000000 --- a/.github/workflows/test_run.yaml +++ /dev/null @@ -1,119 +0,0 @@ -name: manual_test - -on: - workflow_dispatch: - inputs: - tags: - description: 'Specify attack type using tags' - - out_file: - description: 'name of the report file' - required: True - - format: - description: 'format for the report' - - waf_url: - description: 'URL for the waf to be tested' - - cve_id: - description: 'comma separated CVE Ids to test' - - full_report: - description: 'Boolean to generate full report' - -jobs: - Project-runner: - name: Project runner - - env: - TAG: ${{ github.event.inputs.tags }} - OUT_FILE: ${{ github.event.inputs.out_file }} - FORMAT: ${{ github.event.inputs.format }} - WAF_URL: ${{ github.event.inputs.waf_url }} - CVE_ID: ${{ github.event.inputs.cve_id }} - FULL_REPORT: ${{ github.event.inputs.full_report }} - - runs-on: ubuntu-20.04 - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup python - uses: actions/setup-python@v1 - with: - python-version: 3.9 - architecture: x64 - - - name: Install nuclei - # fetch latest nuclei binary, unzip and add to path - run: | - curl https://github.com/projectdiscovery/nuclei/releases/latest -s -L | egrep -o "/projectdiscovery/nuclei/releases/download/v[0-9]\.[0-9]\.[0-9]/nuclei_[0-9]\.[0-9]\.[0-9]_linux_amd64.zip" | wget --base=https://github.com -i - - unzip nuclei*.zip - echo "$PWD" >> $GITHUB_PATH - - - name: install poetry - run: pip install poetry==1.1.13 - - - name: install project - run: poetry install --no-dev - - - name: run program - run: poetry run project-seaweed tester - - - name: upload report - uses: actions/upload-artifact@v3 - with: - name: report-artifact - path: ${{ github.event.inputs.out_file }} - - - name: Successful execution - if: success() - uses: slackapi/slack-github-action@v1.18.0 - with: - payload: | - { - "text": "Program finished successfully!", - "attachments": [ - { - "pretext": "Finished", - "color": "28a745", - "fields": [ - { - "title": "Status", - "short": true, - "value": "Completed" - } - ] - } - ] - } - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK - - - name: Failure - if: failure() - uses: slackapi/slack-github-action@v1.18.0 - with: - payload: | - { - "text": "Program ran into an error", - "attachments": [ - { - "pretext": "Incomplete", - "color": "c91a23", - "fields": [ - { - "title": "Status", - "short": false, - "value": "Incomplete" - } - ] - } - ] - } - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK - diff --git a/README.md b/README.md index 138c8e4..5cc1661 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Project Seaweed -[![Tests](https://github.com/vandanrohatgi/Project-Seaweed/workflows/Tests/badge.svg)](https://github.com/vandanrohatgi/Project-Seaweed/actions?workflow=Tests) +[![Tests](https://github.com/coreruleset/Project-Seaweed/workflows/Tests/badge.svg)](https://github.com/coreruleset/Project-Seaweed/actions?workflow=Tests) ## GSoC meet #11 Summary @@ -45,7 +45,7 @@ This project does not provide the functionality to fetch the logs from CRS conta 1. **Clone the repository** -`git clone https://github.com/vandanrohatgi/Project-Seaweed.git` +`git clone https://github.com/coreruleset/Project-Seaweed.git` 2. **Install poetry** diff --git a/docs/installation.rst b/docs/installation.rst index 03ca50f..c73f610 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -6,7 +6,7 @@ Installation 1. **Clone the repository** -`git clone https://github.com/vandanrohatgi/Project-Seaweed.git` +`git clone https://github.com/coreruleset/Project-Seaweed.git` 2. **Install poetry** diff --git a/src/project_seaweed/report_analyzer.py b/src/project_seaweed/report_analyzer.py index 64caa03..6f1c462 100644 --- a/src/project_seaweed/report_analyzer.py +++ b/src/project_seaweed/report_analyzer.py @@ -2,11 +2,13 @@ import requests import difflib +import os +repo_owner=os.environ.get("REPO_OWNER", default='coreruleset') -file_url: str = "https://raw.githubusercontent.com/vandanrohatgi/Seaweed-Reports/main/{}/{}Artifact/{}Analysis.yaml" +file_url: str = "https://raw.githubusercontent.com/{}/Seaweed-Reports/main/{}/{}Artifact/{}Analysis.yaml" latest_scan: str = ( - "https://raw.githubusercontent.com/vandanrohatgi/Seaweed-Reports/main/latest.txt" + "https://raw.githubusercontent.com/{}/Seaweed-Reports/main/latest.txt" ) @@ -16,7 +18,7 @@ def fetch_latest_test() -> str: Returns: str: directory where the latest test results are stored """ - response: str = requests.get(latest_scan) + response: str = requests.get(latest_scan.format(repo_owner)) dir: str = response.text.strip() return dir @@ -34,8 +36,8 @@ def analyze(date1: str = "", date2: str = "", tag: str = "") -> None: if date1 == "latest": date1 = fetch_latest_test() - response1: str = requests.get(file_url.format(date1, tag, tag)).text - response2: str = requests.get(file_url.format(date2, tag, tag)).text + response1: str = requests.get(file_url.format(repo_owner,date1, tag, tag)).text + response2: str = requests.get(file_url.format(repo_owner,date2, tag, tag)).text for line in difflib.unified_diff( response2.split("\n"),