diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 69d9543..a39e441 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -15,16 +15,20 @@ updates: commit-message: prefix: "chore" include: "scope" + labels: + - "Type: Maintenance" # Maintain dependencies for go modules - package-ecosystem: "gomod" directory: "/" schedule: - interval: "weekly" + interval: "daily" target-branch: "dev" commit-message: prefix: "chore" include: "scope" + labels: + - "Type: Maintenance" # Maintain dependencies for docker - package-ecosystem: "docker" @@ -34,4 +38,6 @@ updates: target-branch: "dev" commit-message: prefix: "chore" - include: "scope" \ No newline at end of file + include: "scope" + labels: + - "Type: Maintenance" \ No newline at end of file diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 3f76a5b..10e0284 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -5,25 +5,38 @@ on: pull_request: workflow_dispatch: - jobs: build: name: Test Builds - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macOS-latest] steps: - - uses: actions/checkout@v2 - - - uses: actions/setup-go@v2 + - name: Set up Go + uses: actions/setup-go@v2 with: go-version: 1.17 - - name: Test - run: go test ./... - - - name: Integration Tests - run: bash run.sh - working-directory: integration_tests/ + - name: Check out code + uses: actions/checkout@v2 - name: Build run: go build . working-directory: cmd/httpx/ + + - name: Test + run: go test ./... + working-directory: . + + - name: Integration Tests + env: + GH_ACTION: true + run: bash run.sh + working-directory: integration_tests/ + + - name: Race Condition Tests + run: go build -race . + working-directory: cmd/httpx/ + + diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 545cdea..792785b 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -2,6 +2,7 @@ name: 🚨 CodeQL Analysis on: workflow_dispatch: + push: pull_request: branches: - dev diff --git a/.github/workflows/functional-test.yml b/.github/workflows/functional-test.yml index 027f3c7..9d48a45 100644 --- a/.github/workflows/functional-test.yml +++ b/.github/workflows/functional-test.yml @@ -4,11 +4,13 @@ on: pull_request: workflow_dispatch: - jobs: functional: name: Functional Test - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macOS-latest] steps: - name: Set up Go uses: actions/setup-go@v2 @@ -21,5 +23,5 @@ jobs: - name: Functional Tests run: | chmod +x run.sh - bash run.sh + bash run.sh ${{ matrix.os }} working-directory: cmd/functional-test diff --git a/.github/workflows/release-binary.yml b/.github/workflows/release-binary.yml index 7cf8f99..657340d 100644 --- a/.github/workflows/release-binary.yml +++ b/.github/workflows/release-binary.yml @@ -9,18 +9,21 @@ jobs: release: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - - uses: actions/setup-go@v2 - with: + - name: "Check out code" + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: "Set up Go" + uses: actions/setup-go@v2 + with: go-version: 1.17 - - - - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - name: "Create release on GitHub" + + - name: "Create release on GitHub" uses: goreleaser/goreleaser-action@v2 - with: + with: args: "release --rm-dist" version: latest workdir: . + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml new file mode 100644 index 0000000..62ad03f --- /dev/null +++ b/.github/workflows/sonarcloud.yml @@ -0,0 +1,38 @@ +name: 👮🏼‍♂️ Sonarcloud +on: + push: + branches: + - master + - dev + pull_request: + types: [opened, synchronize, reopened] + workflow_dispatch: + +jobs: + sonarcloud: + name: SonarCloud + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + + - name: "Set up Go" + uses: actions/setup-go@v2 + with: + go-version: 1.17 + + - name: Run unit Tests + run: | + go test -coverprofile=./cov.out ./... + + - name: Run Gosec Security Scanner + run: | + go install github.com/securego/gosec/cmd/gosec@latest + gosec -no-fail -fmt=sonarqube -out report.json ./... + + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file diff --git a/cmd/functional-test/run.sh b/cmd/functional-test/run.sh index be5e8c7..2d4ddb8 100755 --- a/cmd/functional-test/run.sh +++ b/cmd/functional-test/run.sh @@ -1,13 +1,23 @@ #!/bin/bash -echo 'Building functional-test binary' -go build +# reading os type from arguments +CURRENT_OS=$1 -echo 'Building HTTPX binary from current branch' -go build -o httpx_dev ../httpx +if [ "${CURRENT_OS}" == "windows-latest" ];then + extension=.exe +fi -echo 'Installing latest release of HTTPX' -GO111MODULE=on go build -v github.com/projectdiscovery/httpx/cmd/httpx +echo "::group::Building functional-test binary" +go build -o functional-test$extension +echo "::endgroup::" -echo 'Starting HTTPX functional test' -./functional-test -main ./httpx -dev ./httpx_dev -testcases testcases.txt +echo "::group::Building dnsx binary from current branch" +go build -o httpx_dev$extension ../httpx +echo "::endgroup::" + +echo "::group::Building latest release of dnsx" +go build -o httpx$extension -v github.com/projectdiscovery/httpx/cmd/httpx +echo "::endgroup::" + +echo 'Starting dnsx functional test' +./functional-test$extension -main ./httpx$extension -dev ./httpx_dev$extension -testcases testcases.txt diff --git a/integration_tests/run.sh b/integration_tests/run.sh index cb9cbf3..ab8a110 100755 --- a/integration_tests/run.sh +++ b/integration_tests/run.sh @@ -1,13 +1,17 @@ #!/bin/bash +echo "::group::Build httpx" rm integration-test httpx 2>/dev/null cd ../cmd/httpx go build mv httpx ../../integration_tests/httpx +echo "::endgroup::" +echo "::group::Build httpx integration-test" cd ../integration-test go build mv integration-test ../../integration_tests/integration-test cd ../../integration_tests +echo "::endgroup::" ./integration-test if [ $? -eq 0 ] then diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..1b99918 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,16 @@ +sonar.projectKey=projectdiscovery_httpx +sonar.organization=projectdiscovery + +# This is the name and version displayed in the SonarCloud UI. +#sonar.projectName=dnsx +#sonar.projectVersion=1.0 + +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +sonar.sources=. +sonar.tests=. +sonar.test.inclusions=**/*_test.go +sonar.go.coverage.reportPaths=cov.out +sonar.externalIssuesReportPaths=report.json + +# Encoding of the source code. Default is default system encoding +#sonar.sourceEncoding=UTF-8 \ No newline at end of file