From 73aa124be4da9ffb901de75765f6e100ae5ae710 Mon Sep 17 00:00:00 2001 From: "bram-star-app[bot]" <203639708+bram-star-app[bot]@users.noreply.github.com> Date: Wed, 3 Sep 2025 07:01:51 +0000 Subject: [PATCH 01/12] chore: initialize PR with an empty commit skip-checks:true From 9adc36ae06ba1391ace2fc49a15f271e94c004a8 Mon Sep 17 00:00:00 2001 From: "bram-star-app[bot]" <203639708+bram-star-app[bot]@users.noreply.github.com> Date: Wed, 3 Sep 2025 07:12:41 +0000 Subject: [PATCH 02/12] ci: temporarily disable workflows while addressing security issues skip-checks:true --- .github/workflows/build_and_push_stable.yml | 18 ++++----- .github/workflows/build_and_push_unstable.yml | 18 ++++----- .github/workflows/check-client.yml | 33 ++++++---------- .github/workflows/check.yml | 38 +++++++------------ 4 files changed, 40 insertions(+), 67 deletions(-) diff --git a/.github/workflows/build_and_push_stable.yml b/.github/workflows/build_and_push_stable.yml index fb4885e8..9c482155 100644 --- a/.github/workflows/build_and_push_stable.yml +++ b/.github/workflows/build_and_push_stable.yml @@ -1,9 +1,10 @@ name: "Build and Push Docker Image (On Push to Stable)" - on: - push: - branches: - - stable + workflow_dispatch: +# on: +# push: +# branches: +# - stable jobs: docker-build-push: @@ -11,19 +12,15 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - - name: Login to DockerHub run: | docker login --username=${{ vars.DOCKERHUB_DULL_USER }} --password=${{ secrets.DOCKERHUB_DULL_TOKEN }} - - name: Generate timestamp id: timestamp run: echo "TIMESTAMP=$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV - - name: Generate short SHA id: sha run: echo "SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-6)" >> $GITHUB_ENV - - name: Build and tag Docker images run: | for TAG_PREFIX in stable unstable; do @@ -31,11 +28,10 @@ jobs: docker tag bramkor/pureflow:${TAG_PREFIX} bramkor/pureflow:${TAG_PREFIX}-${{ env.SHORT_SHA }} docker tag bramkor/pureflow:${TAG_PREFIX} bramkor/pureflow:${TAG_PREFIX}-${{ env.SHORT_SHA }}-${{ env.TIMESTAMP }} done - - name: Push Docker images - run: | + run: |- for TAG_PREFIX in stable unstable; do docker push bramkor/pureflow:${TAG_PREFIX} docker push bramkor/pureflow:${TAG_PREFIX}-${{ env.SHORT_SHA }} docker push bramkor/pureflow:${TAG_PREFIX}-${{ env.SHORT_SHA }}-${{ env.TIMESTAMP }} - done \ No newline at end of file + done diff --git a/.github/workflows/build_and_push_unstable.yml b/.github/workflows/build_and_push_unstable.yml index d6e69500..1af4801b 100644 --- a/.github/workflows/build_and_push_unstable.yml +++ b/.github/workflows/build_and_push_unstable.yml @@ -1,11 +1,13 @@ name: "Build and Push Docker Image (Manual)" on: workflow_dispatch: - inputs: - tag_prefix: - description: 'Tag prefix to use (defaults to unstable)' - required: false - default: 'unstable' +# on: +# workflow_dispatch: +# inputs: +# tag_prefix: +# description: 'Tag prefix to use (defaults to unstable)' +# required: false +# default: 'unstable' jobs: docker-build-push: @@ -13,19 +15,15 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - - name: Login to DockerHub run: | docker login --username=${{ vars.DOCKERHUB_DULL_USER }} --password=${{ secrets.DOCKERHUB_DULL_TOKEN }} - - name: Generate timestamp id: timestamp run: echo "TIMESTAMP=$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV - - name: Generate short SHA id: sha run: echo "SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-6)" >> $GITHUB_ENV - - name: Set tag prefix id: set_tag_prefix run: | @@ -36,13 +34,11 @@ jobs: TAG_PREFIX="${{ github.event.inputs.tag_prefix }}" fi echo "TAG_PREFIX=${TAG_PREFIX}" >> $GITHUB_ENV - - name: Build Docker image run: | docker build -t dull/pureflow:${{ env.TAG_PREFIX }} . docker tag dull/pureflow:${{ env.TAG_PREFIX }} brdullc/pureflow:${{ env.TAG_PREFIX }}-${{ env.SHORT_SHA }} docker tag dull/pureflow:${{ env.TAG_PREFIX }} brdullc/pureflow:${{ env.TAG_PREFIX }}-${{ env.SHORT_SHA }}-${{ env.TIMESTAMP }} - - name: Push Docker images run: | docker push dull/pureflow:${{ env.TAG_PREFIX }} diff --git a/.github/workflows/check-client.yml b/.github/workflows/check-client.yml index ada35f1d..2f0237b7 100644 --- a/.github/workflows/check-client.yml +++ b/.github/workflows/check-client.yml @@ -1,26 +1,23 @@ name: "React Front-End CI checks" - on: - pull_request: - branches: - - '**' - - push: - branches: - - stable - - unstable - - paths: - - 'client/**' - - '.github/workflows/*client.yml' + workflow_dispatch: +# on: +# pull_request: +# branches: +# - '**' +# push: +# branches: +# - stable +# - unstable +# paths: +# - 'client/**' +# - '.github/workflows/*client.yml' env: HUSKY: 0 - concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true - jobs: check: runs-on: ubuntu-latest @@ -30,23 +27,17 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - - name: Setup Node.js ${{ matrix.node-version }} uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - - name: Disable prepare script (husky) run: npm pkg delete scripts.prepare - - name: Install dependencies run: npm ci --prefix=client --no-audit - - name: Check format run: npm run format --prefix=client - - name: Lint run: npm run lint --prefix=client - - name: Build run: npm run build --prefix=client diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 409c9b86..94023959 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -1,28 +1,25 @@ name: "Nest Back-End CI checks" - on: - pull_request: - branches: - - '**' - - push: - branches: - - stable - - unstable - - paths: - - '*' - - 'src/**' - - 'test/**' - - '.github/workflows/check.yml' + workflow_dispatch: +# on: +# pull_request: +# branches: +# - '**' +# push: +# branches: +# - stable +# - unstable +# paths: +# - '*' +# - 'src/**' +# - 'test/**' +# - '.github/workflows/check.yml' env: HUSKY: 0 - concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true - jobs: check: runs-on: ubuntu-latest @@ -32,26 +29,19 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - - name: Setup Node.js ${{ matrix.node-version }} uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - - name: Disable prepare script (husky) run: npm pkg delete scripts.prepare - - name: Install dependencies run: npm ci --no-audit - - name: Check format run: npm run format - - name: Lint run: npm run lint - - name: Build run: npm run build - - name: Test run: npm run test From 3e88cd64e9de51c334075463f59cd6c0d5425f42 Mon Sep 17 00:00:00 2001 From: "bram-star-app[bot]" <203639708+bram-star-app[bot]@users.noreply.github.com> Date: Wed, 3 Sep 2025 07:22:35 +0000 Subject: [PATCH 03/12] test: add auto-generated e2e security tests skip-checks:true --- .../delete-api-email-delete-emails.test.ts | 34 ++++++++++++++ ...ig-products-crystals-some-file-jpg.test.ts | 34 ++++++++++++++ .../tests/get-api-auth-dom-csrf-flow.test.ts | 35 ++++++++++++++ .../tests/get-api-auth-oidc-client.test.ts | 34 ++++++++++++++ .../get-api-auth-simple-csrf-flow.test.ts | 34 ++++++++++++++ .../tests/get-api-email-get-emails.test.ts | 34 ++++++++++++++ .../get-api-email-send-support-email.test.ts | 35 ++++++++++++++ .brightsec/tests/get-api-file-aws.test.ts | 35 ++++++++++++++ .brightsec/tests/get-api-file-azure.test.ts | 35 ++++++++++++++ .../tests/get-api-file-digital-ocean.test.ts | 35 ++++++++++++++ .brightsec/tests/get-api-file-google.test.ts | 35 ++++++++++++++ ...ystals-amethyst-jpg-type-image-jpg.test.ts | 35 ++++++++++++++ ...fig-products-crystals-amethyst-jpg.test.ts | 35 ++++++++++++++ .brightsec/tests/get-api-goto.test.ts | 34 ++++++++++++++ .../tests/get-api-nestedjson-depth-2.test.ts | 35 ++++++++++++++ .../get-api-partners-partner-login.test.ts | 35 ++++++++++++++ .../tests/get-api-partners-query.test.ts | 35 ++++++++++++++ .../get-api-partners-search-partners.test.ts | 35 ++++++++++++++ .../tests/get-api-products-latest.test.ts | 35 ++++++++++++++ .../tests/get-api-products-views.test.ts | 35 ++++++++++++++ .brightsec/tests/get-api-secrets.test.ts | 34 ++++++++++++++ .../tests/get-api-spawn-command-ls-la.test.ts | 35 ++++++++++++++ .../tests/get-api-testimonials-count.test.ts | 35 ++++++++++++++ .brightsec/tests/get-api-testimonials.test.ts | 34 ++++++++++++++ .../get-api-users-fullinfo-email.test.ts | 34 ++++++++++++++ .brightsec/tests/get-api-users-ldap.test.ts | 34 ++++++++++++++ .../tests/get-api-users-one-email.test.ts | 34 ++++++++++++++ .../tests/get-api-users-search-john.test.ts | 34 ++++++++++++++ .../tests/get-api-v1-userinfo-email.test.ts | 34 ++++++++++++++ .../tests/get-graphql-command-ls.test.ts | 34 ++++++++++++++ .brightsec/tests/get-graphql.test.ts | 34 ++++++++++++++ .brightsec/tests/options-api.test.ts | 35 ++++++++++++++ .../tests/post-api-auth-admin-login.test.ts | 40 ++++++++++++++++ .../post-api-auth-jwt-hmac-login.test.ts | 40 ++++++++++++++++ .../tests/post-api-auth-jwt-jku-login.test.ts | 40 ++++++++++++++++ .../tests/post-api-auth-jwt-jwk-login.test.ts | 40 ++++++++++++++++ .../post-api-auth-jwt-kid-sql-login.test.ts | 43 +++++++++++++++++ .../post-api-auth-jwt-weak-key-login.test.ts | 40 ++++++++++++++++ .../tests/post-api-auth-jwt-x5c-login.test.ts | 40 ++++++++++++++++ .../tests/post-api-auth-jwt-x5u-login.test.ts | 43 +++++++++++++++++ .brightsec/tests/post-api-auth-login.test.ts | 43 +++++++++++++++++ .brightsec/tests/post-api-chat-query.test.ts | 36 +++++++++++++++ .brightsec/tests/post-api-metadata.test.ts | 36 +++++++++++++++ .brightsec/tests/post-api-render.test.ts | 36 +++++++++++++++ .../tests/post-api-subscriptions.test.ts | 34 ++++++++++++++ .brightsec/tests/post-api-users-basic.test.ts | 45 ++++++++++++++++++ .brightsec/tests/post-api-users-oidc.test.ts | 46 +++++++++++++++++++ .../post-graphql-all-testimonials.test.ts | 38 +++++++++++++++ .../post-graphql-get-command-result.test.ts | 39 ++++++++++++++++ .../post-graphql-latest-products.test.ts | 38 +++++++++++++++ .../post-graphql-testimonials-count.test.ts | 39 ++++++++++++++++ .../tests/post-graphql-view-product.test.ts | 39 ++++++++++++++++ ...ile-raw-path-some-path-to-file-png.test.ts | 36 +++++++++++++++ 53 files changed, 1936 insertions(+) create mode 100644 .brightsec/tests/delete-api-email-delete-emails.test.ts create mode 100644 .brightsec/tests/delete-api-file-path-config-products-crystals-some-file-jpg.test.ts create mode 100644 .brightsec/tests/get-api-auth-dom-csrf-flow.test.ts create mode 100644 .brightsec/tests/get-api-auth-oidc-client.test.ts create mode 100644 .brightsec/tests/get-api-auth-simple-csrf-flow.test.ts create mode 100644 .brightsec/tests/get-api-email-get-emails.test.ts create mode 100644 .brightsec/tests/get-api-email-send-support-email.test.ts create mode 100644 .brightsec/tests/get-api-file-aws.test.ts create mode 100644 .brightsec/tests/get-api-file-azure.test.ts create mode 100644 .brightsec/tests/get-api-file-digital-ocean.test.ts create mode 100644 .brightsec/tests/get-api-file-google.test.ts create mode 100644 .brightsec/tests/get-api-file-path-config-products-crystals-amethyst-jpg-type-image-jpg.test.ts create mode 100644 .brightsec/tests/get-api-file-raw-path-config-products-crystals-amethyst-jpg.test.ts create mode 100644 .brightsec/tests/get-api-goto.test.ts create mode 100644 .brightsec/tests/get-api-nestedjson-depth-2.test.ts create mode 100644 .brightsec/tests/get-api-partners-partner-login.test.ts create mode 100644 .brightsec/tests/get-api-partners-query.test.ts create mode 100644 .brightsec/tests/get-api-partners-search-partners.test.ts create mode 100644 .brightsec/tests/get-api-products-latest.test.ts create mode 100644 .brightsec/tests/get-api-products-views.test.ts create mode 100644 .brightsec/tests/get-api-secrets.test.ts create mode 100644 .brightsec/tests/get-api-spawn-command-ls-la.test.ts create mode 100644 .brightsec/tests/get-api-testimonials-count.test.ts create mode 100644 .brightsec/tests/get-api-testimonials.test.ts create mode 100644 .brightsec/tests/get-api-users-fullinfo-email.test.ts create mode 100644 .brightsec/tests/get-api-users-ldap.test.ts create mode 100644 .brightsec/tests/get-api-users-one-email.test.ts create mode 100644 .brightsec/tests/get-api-users-search-john.test.ts create mode 100644 .brightsec/tests/get-api-v1-userinfo-email.test.ts create mode 100644 .brightsec/tests/get-graphql-command-ls.test.ts create mode 100644 .brightsec/tests/get-graphql.test.ts create mode 100644 .brightsec/tests/options-api.test.ts create mode 100644 .brightsec/tests/post-api-auth-admin-login.test.ts create mode 100644 .brightsec/tests/post-api-auth-jwt-hmac-login.test.ts create mode 100644 .brightsec/tests/post-api-auth-jwt-jku-login.test.ts create mode 100644 .brightsec/tests/post-api-auth-jwt-jwk-login.test.ts create mode 100644 .brightsec/tests/post-api-auth-jwt-kid-sql-login.test.ts create mode 100644 .brightsec/tests/post-api-auth-jwt-weak-key-login.test.ts create mode 100644 .brightsec/tests/post-api-auth-jwt-x5c-login.test.ts create mode 100644 .brightsec/tests/post-api-auth-jwt-x5u-login.test.ts create mode 100644 .brightsec/tests/post-api-auth-login.test.ts create mode 100644 .brightsec/tests/post-api-chat-query.test.ts create mode 100644 .brightsec/tests/post-api-metadata.test.ts create mode 100644 .brightsec/tests/post-api-render.test.ts create mode 100644 .brightsec/tests/post-api-subscriptions.test.ts create mode 100644 .brightsec/tests/post-api-users-basic.test.ts create mode 100644 .brightsec/tests/post-api-users-oidc.test.ts create mode 100644 .brightsec/tests/post-graphql-all-testimonials.test.ts create mode 100644 .brightsec/tests/post-graphql-get-command-result.test.ts create mode 100644 .brightsec/tests/post-graphql-latest-products.test.ts create mode 100644 .brightsec/tests/post-graphql-testimonials-count.test.ts create mode 100644 .brightsec/tests/post-graphql-view-product.test.ts create mode 100644 .brightsec/tests/put-api-file-raw-path-some-path-to-file-png.test.ts diff --git a/.brightsec/tests/delete-api-email-delete-emails.test.ts b/.brightsec/tests/delete-api-email-delete-emails.test.ts new file mode 100644 index 00000000..8deb0722 --- /dev/null +++ b/.brightsec/tests/delete-api-email-delete-emails.test.ts @@ -0,0 +1,34 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('DELETE /api/email/deleteEmails', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['csrf', 'bopla', 'improper_asset_management'], + attackParamLocations: [AttackParamLocation.PATH], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.DELETE, + url: `${baseUrl}/api/email/deleteEmails` + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/delete-api-file-path-config-products-crystals-some-file-jpg.test.ts b/.brightsec/tests/delete-api-file-path-config-products-crystals-some-file-jpg.test.ts new file mode 100644 index 00000000..1e2439f4 --- /dev/null +++ b/.brightsec/tests/delete-api-file-path-config-products-crystals-some-file-jpg.test.ts @@ -0,0 +1,34 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('DELETE /api/file?path=config/products/crystals/some_file.jpg', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['lfi', 'ssrf', 'bopla', 'sqli', 'csrf'], + attackParamLocations: [AttackParamLocation.QUERY], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.DELETE, + url: `${baseUrl}/api/file?path=config/products/crystals/some_file.jpg` + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-auth-dom-csrf-flow.test.ts b/.brightsec/tests/get-api-auth-dom-csrf-flow.test.ts new file mode 100644 index 00000000..ea277550 --- /dev/null +++ b/.brightsec/tests/get-api-auth-dom-csrf-flow.test.ts @@ -0,0 +1,35 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('GET /api/auth/dom-csrf-flow', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['csrf', 'xss', 'full_path_disclosure'], + attackParamLocations: [AttackParamLocation.HEADER], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.GET, + url: `${baseUrl}/api/auth/dom-csrf-flow`, + headers: { fingerprint: 'example-fingerprint' } + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-auth-oidc-client.test.ts b/.brightsec/tests/get-api-auth-oidc-client.test.ts new file mode 100644 index 00000000..dfca392d --- /dev/null +++ b/.brightsec/tests/get-api-auth-oidc-client.test.ts @@ -0,0 +1,34 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('GET /api/auth/oidc-client', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['csrf', 'secret_tokens', 'open_database', 'xss'], + attackParamLocations: [AttackParamLocation.HEADER, AttackParamLocation.PATH, AttackParamLocation.QUERY], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.GET, + url: `${baseUrl}/api/auth/oidc-client` + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-auth-simple-csrf-flow.test.ts b/.brightsec/tests/get-api-auth-simple-csrf-flow.test.ts new file mode 100644 index 00000000..0c7e6990 --- /dev/null +++ b/.brightsec/tests/get-api-auth-simple-csrf-flow.test.ts @@ -0,0 +1,34 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('GET /api/auth/simple-csrf-flow', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['csrf', 'xss', 'secret_tokens'], + attackParamLocations: [AttackParamLocation.HEADER, AttackParamLocation.PATH], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.GET, + url: `${baseUrl}/api/auth/simple-csrf-flow` + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-email-get-emails.test.ts b/.brightsec/tests/get-api-email-get-emails.test.ts new file mode 100644 index 00000000..f7512b6a --- /dev/null +++ b/.brightsec/tests/get-api-email-get-emails.test.ts @@ -0,0 +1,34 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('GET /api/email/getEmails?withSource=true', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['proto_pollution', 'business_constraint_bypass', 'csrf', 'xss'], + attackParamLocations: [AttackParamLocation.QUERY], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.GET, + url: `${baseUrl}/api/email/getEmails?withSource=true` + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-email-send-support-email.test.ts b/.brightsec/tests/get-api-email-send-support-email.test.ts new file mode 100644 index 00000000..cd09d91f --- /dev/null +++ b/.brightsec/tests/get-api-email-send-support-email.test.ts @@ -0,0 +1,35 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('GET /api/email/sendSupportEmail', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['proto_pollution', 'email_injection', 'xss'], + attackParamLocations: [AttackParamLocation.QUERY], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.GET, + url: `${baseUrl}/api/email/sendSupportEmail?name=Bob%20Dylan&to=username%40email.com&subject=Help%20Request&content=I%20would%20like%20to%20request%20help%20regarding..`, + headers: { 'Content-Type': 'application/json' } + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-file-aws.test.ts b/.brightsec/tests/get-api-file-aws.test.ts new file mode 100644 index 00000000..99409b6a --- /dev/null +++ b/.brightsec/tests/get-api-file-aws.test.ts @@ -0,0 +1,35 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('GET /api/file/aws', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['amazon_s3_takeover', 'ssrf', 'lfi', 'open_cloud_storage', 'secret_tokens'], + attackParamLocations: [AttackParamLocation.QUERY, AttackParamLocation.HEADER], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.GET, + url: `${baseUrl}/api/file/aws?path=config/products/crystals/amethyst.jpg&type=image/jpg`, + headers: { accept: 'image/jpg' } + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-file-azure.test.ts b/.brightsec/tests/get-api-file-azure.test.ts new file mode 100644 index 00000000..f865ec68 --- /dev/null +++ b/.brightsec/tests/get-api-file-azure.test.ts @@ -0,0 +1,35 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('GET /api/file/azure', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['open_cloud_storage', 'lfi', 'ssrf', 'unvalidated_redirect'], + attackParamLocations: [AttackParamLocation.QUERY, AttackParamLocation.HEADER], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.GET, + url: `${baseUrl}/api/file/azure?path=config/products/crystals/amethyst.jpg&type=image/jpg`, + headers: { accept: 'image/jpg' } + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-file-digital-ocean.test.ts b/.brightsec/tests/get-api-file-digital-ocean.test.ts new file mode 100644 index 00000000..91371977 --- /dev/null +++ b/.brightsec/tests/get-api-file-digital-ocean.test.ts @@ -0,0 +1,35 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('GET /api/file/digital_ocean', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['ssrf', 'lfi', 'open_cloud_storage', 'file_upload'], + attackParamLocations: [AttackParamLocation.QUERY, AttackParamLocation.HEADER], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.GET, + url: `${baseUrl}/api/file/digital_ocean?path=config/products/crystals/amethyst.jpg&type=image/jpg`, + headers: { accept: 'image/jpg' } + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-file-google.test.ts b/.brightsec/tests/get-api-file-google.test.ts new file mode 100644 index 00000000..9342bb66 --- /dev/null +++ b/.brightsec/tests/get-api-file-google.test.ts @@ -0,0 +1,35 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('GET /api/file/google', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['ssrf', 'lfi', 'open_cloud_storage', 'file_upload'], + attackParamLocations: [AttackParamLocation.QUERY, AttackParamLocation.HEADER], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.GET, + url: `${baseUrl}/api/file/google?path=config/products/crystals/amethyst.jpg&type=image/jpg`, + headers: { accept: 'image/jpg' } + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-file-path-config-products-crystals-amethyst-jpg-type-image-jpg.test.ts b/.brightsec/tests/get-api-file-path-config-products-crystals-amethyst-jpg-type-image-jpg.test.ts new file mode 100644 index 00000000..575b01b6 --- /dev/null +++ b/.brightsec/tests/get-api-file-path-config-products-crystals-amethyst-jpg-type-image-jpg.test.ts @@ -0,0 +1,35 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('GET /api/file?path=config/products/crystals/amethyst.jpg&type=image/jpg', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['lfi', 'ssrf', 'open_cloud_storage', 'file_upload', 'full_path_disclosure'], + attackParamLocations: [AttackParamLocation.QUERY], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.GET, + url: `${baseUrl}/api/file?path=config/products/crystals/amethyst.jpg&type=image/jpg`, + headers: { accept: 'image/jpg' } + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-file-raw-path-config-products-crystals-amethyst-jpg.test.ts b/.brightsec/tests/get-api-file-raw-path-config-products-crystals-amethyst-jpg.test.ts new file mode 100644 index 00000000..ba789047 --- /dev/null +++ b/.brightsec/tests/get-api-file-raw-path-config-products-crystals-amethyst-jpg.test.ts @@ -0,0 +1,35 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('GET /api/file/raw?path=config/products/crystals/amethyst.jpg', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['lfi', 'ssrf', 'full_path_disclosure', 'open_cloud_storage'], + attackParamLocations: [AttackParamLocation.QUERY], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.GET, + url: `${baseUrl}/api/file/raw?path=config/products/crystals/amethyst.jpg`, + headers: { accept: 'image/jpg' } + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-goto.test.ts b/.brightsec/tests/get-api-goto.test.ts new file mode 100644 index 00000000..32a30e02 --- /dev/null +++ b/.brightsec/tests/get-api-goto.test.ts @@ -0,0 +1,34 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('GET /api/goto', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['unvalidated_redirect', 'ssrf'], + attackParamLocations: [AttackParamLocation.QUERY], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.GET, + url: `${baseUrl}/api/goto?url=https://google.com` + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-nestedjson-depth-2.test.ts b/.brightsec/tests/get-api-nestedjson-depth-2.test.ts new file mode 100644 index 00000000..650e1fb2 --- /dev/null +++ b/.brightsec/tests/get-api-nestedjson-depth-2.test.ts @@ -0,0 +1,35 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('GET /api/nestedJson?depth=2', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['business_constraint_bypass', 'osi', 'xss'], + attackParamLocations: [AttackParamLocation.QUERY], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.GET, + url: `${baseUrl}/api/nestedJson?depth=2`, + headers: { 'Content-Type': 'application/json' } + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-partners-partner-login.test.ts b/.brightsec/tests/get-api-partners-partner-login.test.ts new file mode 100644 index 00000000..ff7366a1 --- /dev/null +++ b/.brightsec/tests/get-api-partners-partner-login.test.ts @@ -0,0 +1,35 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('GET /api/partners/partnerLogin', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['xpathi', 'xss', 'full_path_disclosure'], + attackParamLocations: [AttackParamLocation.QUERY], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.GET, + url: `${baseUrl}/api/partners/partnerLogin?username=walter100&password=Heisenberg123`, + headers: { 'Content-Type': 'text/xml' } + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-partners-query.test.ts b/.brightsec/tests/get-api-partners-query.test.ts new file mode 100644 index 00000000..c9d9d3d2 --- /dev/null +++ b/.brightsec/tests/get-api-partners-query.test.ts @@ -0,0 +1,35 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('GET /api/partners/query', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['xpathi', 'xss', 'full_path_disclosure'], + attackParamLocations: [AttackParamLocation.QUERY], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.GET, + url: `${baseUrl}/api/partners/query?xpath=%2Fpartners%2Fpartner%2Fname`, + headers: { 'Content-Type': 'text/xml' } + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-partners-search-partners.test.ts b/.brightsec/tests/get-api-partners-search-partners.test.ts new file mode 100644 index 00000000..42447fb9 --- /dev/null +++ b/.brightsec/tests/get-api-partners-search-partners.test.ts @@ -0,0 +1,35 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('GET /api/partners/searchPartners', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['xpathi', 'xss', 'csrf'], + attackParamLocations: [AttackParamLocation.QUERY, AttackParamLocation.HEADER], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.GET, + url: `${baseUrl}/api/partners/searchPartners?keyword=Walter`, + headers: { 'Content-Type': 'text/xml' } + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-products-latest.test.ts b/.brightsec/tests/get-api-products-latest.test.ts new file mode 100644 index 00000000..63c2ae4c --- /dev/null +++ b/.brightsec/tests/get-api-products-latest.test.ts @@ -0,0 +1,35 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('GET /api/products/latest', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['business_constraint_bypass', 'sqli', 'date_manipulation'], + attackParamLocations: [AttackParamLocation.QUERY], + starMetadata: { databases: ['PostgreSQL'] }, + skipStaticParams: false + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.GET, + url: `${baseUrl}/api/products/latest?limit=3` + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-products-views.test.ts b/.brightsec/tests/get-api-products-views.test.ts new file mode 100644 index 00000000..cdd65d02 --- /dev/null +++ b/.brightsec/tests/get-api-products-views.test.ts @@ -0,0 +1,35 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('GET /api/products/views', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['sqli', 'xss', 'csrf', 'business_constraint_bypass', 'full_path_disclosure'], + attackParamLocations: [AttackParamLocation.HEADER], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.GET, + url: `${baseUrl}/api/products/views`, + headers: { 'x-product-name': 'Amethyst' } + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-secrets.test.ts b/.brightsec/tests/get-api-secrets.test.ts new file mode 100644 index 00000000..bbfe69ab --- /dev/null +++ b/.brightsec/tests/get-api-secrets.test.ts @@ -0,0 +1,34 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('GET /api/secrets', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['secret_tokens', 'csrf', 'improper_asset_management', 'unvalidated_redirect'], + attackParamLocations: [AttackParamLocation.HEADER, AttackParamLocation.PATH], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.GET, + url: `${baseUrl}/api/secrets` + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-spawn-command-ls-la.test.ts b/.brightsec/tests/get-api-spawn-command-ls-la.test.ts new file mode 100644 index 00000000..1bab8cbc --- /dev/null +++ b/.brightsec/tests/get-api-spawn-command-ls-la.test.ts @@ -0,0 +1,35 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('GET /api/spawn?command=ls-la', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['osi', 'full_path_disclosure', 'secret_tokens'], + attackParamLocations: [AttackParamLocation.QUERY], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.GET, + url: `${baseUrl}/api/spawn?command=ls%20-la`, + headers: { allow: 'OPTIONS, GET, HEAD, POST' } + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-testimonials-count.test.ts b/.brightsec/tests/get-api-testimonials-count.test.ts new file mode 100644 index 00000000..8b20c8c2 --- /dev/null +++ b/.brightsec/tests/get-api-testimonials-count.test.ts @@ -0,0 +1,35 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('GET /api/testimonials/count', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['sqli', 'full_path_disclosure', 'business_constraint_bypass'], + attackParamLocations: [AttackParamLocation.QUERY], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.GET, + url: `${baseUrl}/api/testimonials/count?query=select%20count(*)%20as%20count%20from%20testimonial`, + headers: { 'Content-Type': 'text/html' } + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-testimonials.test.ts b/.brightsec/tests/get-api-testimonials.test.ts new file mode 100644 index 00000000..44e5d7fb --- /dev/null +++ b/.brightsec/tests/get-api-testimonials.test.ts @@ -0,0 +1,34 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('GET /api/testimonials', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['sqli', 'csrf', 'xss', 'business_constraint_bypass'], + attackParamLocations: [AttackParamLocation.QUERY, AttackParamLocation.HEADER], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.GET, + url: `${baseUrl}/api/testimonials` + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-users-fullinfo-email.test.ts b/.brightsec/tests/get-api-users-fullinfo-email.test.ts new file mode 100644 index 00000000..653e771f --- /dev/null +++ b/.brightsec/tests/get-api-users-fullinfo-email.test.ts @@ -0,0 +1,34 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('GET /api/users/fullinfo/:email', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['bopla', 'id_enumeration', 'xss', 'sqli', 'csrf'], + attackParamLocations: [AttackParamLocation.PATH], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.GET, + url: `${baseUrl}/api/users/fullinfo/john.doe@example.com` + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-users-ldap.test.ts b/.brightsec/tests/get-api-users-ldap.test.ts new file mode 100644 index 00000000..13eba27a --- /dev/null +++ b/.brightsec/tests/get-api-users-ldap.test.ts @@ -0,0 +1,34 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('GET /api/users/ldap', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['ldapi', 'xss', 'full_path_disclosure'], + attackParamLocations: [AttackParamLocation.QUERY], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.GET, + url: `${baseUrl}/api/users/ldap?query=%28%26%28objectClass%3Dperson%29%28objectClass%3Duser%29%28email%3Djohn.doe%40example.com%29%29` + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-users-one-email.test.ts b/.brightsec/tests/get-api-users-one-email.test.ts new file mode 100644 index 00000000..a80bdf71 --- /dev/null +++ b/.brightsec/tests/get-api-users-one-email.test.ts @@ -0,0 +1,34 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('GET /api/users/one/:email', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['bopla', 'csrf', 'email_injection', 'id_enumeration', 'jwt', 'xss'], + attackParamLocations: [AttackParamLocation.PATH], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.GET, + url: `${baseUrl}/api/users/one/john.doe@example.com` + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-users-search-john.test.ts b/.brightsec/tests/get-api-users-search-john.test.ts new file mode 100644 index 00000000..1747b1e8 --- /dev/null +++ b/.brightsec/tests/get-api-users-search-john.test.ts @@ -0,0 +1,34 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('GET /api/users/search/john', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['sqli', 'xss', 'id_enumeration', 'business_constraint_bypass'], + attackParamLocations: [AttackParamLocation.PATH], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.GET, + url: `${baseUrl}/api/users/search/john` + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-v1-userinfo-email.test.ts b/.brightsec/tests/get-api-v1-userinfo-email.test.ts new file mode 100644 index 00000000..03a8bc5d --- /dev/null +++ b/.brightsec/tests/get-api-v1-userinfo-email.test.ts @@ -0,0 +1,34 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('GET /api/v1/userinfo/:email', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['id_enumeration', 'xss', 'bopla', 'csrf', 'secret_tokens'], + attackParamLocations: [AttackParamLocation.PATH], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.GET, + url: `${baseUrl}/api/v1/userinfo/john.doe@example.com` + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/get-graphql-command-ls.test.ts b/.brightsec/tests/get-graphql-command-ls.test.ts new file mode 100644 index 00000000..7c8cad23 --- /dev/null +++ b/.brightsec/tests/get-graphql-command-ls.test.ts @@ -0,0 +1,34 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('GET /graphql?command=ls', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['osi', 'graphql_introspection', 'xss', 'ssrf'], + attackParamLocations: [AttackParamLocation.QUERY], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.GET, + url: `${baseUrl}/graphql?command=ls` + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/get-graphql.test.ts b/.brightsec/tests/get-graphql.test.ts new file mode 100644 index 00000000..59d7e609 --- /dev/null +++ b/.brightsec/tests/get-graphql.test.ts @@ -0,0 +1,34 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('GET /graphql', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['graphql_introspection', 'sqli', 'csrf', 'xss'], + attackParamLocations: [AttackParamLocation.QUERY], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.GET, + url: `${baseUrl}/graphql?query={test}` + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/options-api.test.ts b/.brightsec/tests/options-api.test.ts new file mode 100644 index 00000000..200567cf --- /dev/null +++ b/.brightsec/tests/options-api.test.ts @@ -0,0 +1,35 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('OPTIONS /api', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['http_method_fuzzing', 'csrf'], + attackParamLocations: [AttackParamLocation.HEADER], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.OPTIONS, + url: `${baseUrl}/api`, + headers: { allow: 'OPTIONS, GET, HEAD, POST' } + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/post-api-auth-admin-login.test.ts b/.brightsec/tests/post-api-auth-admin-login.test.ts new file mode 100644 index 00000000..d3718e92 --- /dev/null +++ b/.brightsec/tests/post-api-auth-admin-login.test.ts @@ -0,0 +1,40 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('POST /api/auth/admin/login', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['csrf', 'jwt', 'sqli', 'osi', 'unvalidated_redirect'], + attackParamLocations: [AttackParamLocation.BODY], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.POST, + url: `${baseUrl}/api/auth/admin/login`, + body: { + user: 'john', + password: 'Pa55w0rd', + op: 'basic' + }, + headers: { 'Content-Type': 'application/json' } + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/post-api-auth-jwt-hmac-login.test.ts b/.brightsec/tests/post-api-auth-jwt-hmac-login.test.ts new file mode 100644 index 00000000..11c02ee4 --- /dev/null +++ b/.brightsec/tests/post-api-auth-jwt-hmac-login.test.ts @@ -0,0 +1,40 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('POST /api/auth/jwt/hmac/login', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['csrf', 'jwt', 'sqli', 'osi', 'xss'], + attackParamLocations: [AttackParamLocation.BODY], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.POST, + url: `${baseUrl}/api/auth/jwt/hmac/login`, + body: { + user: 'john', + password: 'Pa55w0rd', + op: 'basic' + }, + headers: { 'Content-Type': 'application/json' } + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/post-api-auth-jwt-jku-login.test.ts b/.brightsec/tests/post-api-auth-jwt-jku-login.test.ts new file mode 100644 index 00000000..81330bbc --- /dev/null +++ b/.brightsec/tests/post-api-auth-jwt-jku-login.test.ts @@ -0,0 +1,40 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('POST /api/auth/jwt/jku/login', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['jwt', 'csrf', 'sqli', 'osi', 'unvalidated_redirect'], + attackParamLocations: [AttackParamLocation.BODY], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.POST, + url: `${baseUrl}/api/auth/jwt/jku/login`, + body: { + user: 'john', + password: 'Pa55w0rd', + op: 'basic' + }, + headers: { 'Content-Type': 'application/json' } + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/post-api-auth-jwt-jwk-login.test.ts b/.brightsec/tests/post-api-auth-jwt-jwk-login.test.ts new file mode 100644 index 00000000..3f5a36f3 --- /dev/null +++ b/.brightsec/tests/post-api-auth-jwt-jwk-login.test.ts @@ -0,0 +1,40 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('POST /api/auth/jwt/jwk/login', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['jwt', 'csrf', 'sqli', 'osi', 'xss'], + attackParamLocations: [AttackParamLocation.BODY], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.POST, + url: `${baseUrl}/api/auth/jwt/jwk/login`, + body: { + user: 'john', + password: 'Pa55w0rd', + op: 'basic' + }, + headers: { 'Content-Type': 'application/json' } + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/post-api-auth-jwt-kid-sql-login.test.ts b/.brightsec/tests/post-api-auth-jwt-kid-sql-login.test.ts new file mode 100644 index 00000000..f7366ed9 --- /dev/null +++ b/.brightsec/tests/post-api-auth-jwt-kid-sql-login.test.ts @@ -0,0 +1,43 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('POST /api/auth/jwt/kid-sql/login', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['sqli', 'jwt', 'csrf', 'xss', 'osi'], + attackParamLocations: [AttackParamLocation.BODY, AttackParamLocation.HEADER], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.POST, + url: `${baseUrl}/api/auth/jwt/kid-sql/login`, + body: { + user: 'john', + password: 'Pa55w0rd', + op: 'basic' + }, + headers: { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjoiam9obkBleGFtcGxlLmNvbSIsImV4cCI6MTYwOTI3MzYwMH0.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c' + } + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/post-api-auth-jwt-weak-key-login.test.ts b/.brightsec/tests/post-api-auth-jwt-weak-key-login.test.ts new file mode 100644 index 00000000..a4dea4f4 --- /dev/null +++ b/.brightsec/tests/post-api-auth-jwt-weak-key-login.test.ts @@ -0,0 +1,40 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('POST /api/auth/jwt/weak-key/login', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['jwt', 'csrf', 'sqli', 'secret_tokens'], + attackParamLocations: [AttackParamLocation.BODY], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.POST, + url: `${baseUrl}/api/auth/jwt/weak-key/login`, + body: { + user: 'john', + password: 'Pa55w0rd', + op: 'basic' + }, + headers: { 'Content-Type': 'application/json' } + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/post-api-auth-jwt-x5c-login.test.ts b/.brightsec/tests/post-api-auth-jwt-x5c-login.test.ts new file mode 100644 index 00000000..734ce0d4 --- /dev/null +++ b/.brightsec/tests/post-api-auth-jwt-x5c-login.test.ts @@ -0,0 +1,40 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('POST /api/auth/jwt/x5c/login', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['jwt', 'csrf', 'sqli', 'osi', 'secret_tokens'], + attackParamLocations: [AttackParamLocation.BODY], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.POST, + url: `${baseUrl}/api/auth/jwt/x5c/login`, + body: { + user: 'john', + password: 'Pa55w0rd', + op: 'basic' + }, + headers: { 'Content-Type': 'application/json' } + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/post-api-auth-jwt-x5u-login.test.ts b/.brightsec/tests/post-api-auth-jwt-x5u-login.test.ts new file mode 100644 index 00000000..e984c52c --- /dev/null +++ b/.brightsec/tests/post-api-auth-jwt-x5u-login.test.ts @@ -0,0 +1,43 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('POST /api/auth/jwt/x5u/login', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['jwt', 'csrf', 'sqli', 'bopla', 'osi'], + attackParamLocations: [AttackParamLocation.BODY, AttackParamLocation.HEADER], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.POST, + url: `${baseUrl}/api/auth/jwt/x5u/login`, + body: { + user: 'john', + password: 'Pa55w0rd', + op: 'basic' + }, + headers: { + 'Content-Type': 'application/json', + Authorization: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjoiam9obkBleGFtcGxlLmNvbSIsImV4cCI6MTYwOTI3MzYwMH0.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c' + } + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/post-api-auth-login.test.ts b/.brightsec/tests/post-api-auth-login.test.ts new file mode 100644 index 00000000..82d2f549 --- /dev/null +++ b/.brightsec/tests/post-api-auth-login.test.ts @@ -0,0 +1,43 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('POST /api/auth/login', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['csrf', 'jwt', 'sqli', 'bopla', 'osi', 'xss'], + attackParamLocations: [AttackParamLocation.BODY, AttackParamLocation.HEADER], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.POST, + url: `${baseUrl}/api/auth/login`, + body: { + user: 'john', + password: 'Pa55w0rd', + op: 'basic' + }, + headers: { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c' + } + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/post-api-chat-query.test.ts b/.brightsec/tests/post-api-chat-query.test.ts new file mode 100644 index 00000000..4c7207b7 --- /dev/null +++ b/.brightsec/tests/post-api-chat-query.test.ts @@ -0,0 +1,36 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('POST /api/chat/query', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['csrf', 'prompt_injection', 'secret_tokens', 'server_side_js_injection', 'ssrf'], + attackParamLocations: [AttackParamLocation.BODY], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.POST, + url: `${baseUrl}/api/chat/query`, + body: [{ role: 'user', content: 'Hello, how are you?' }], + headers: { 'Content-Type': 'application/json' } + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/post-api-metadata.test.ts b/.brightsec/tests/post-api-metadata.test.ts new file mode 100644 index 00000000..c0d1e538 --- /dev/null +++ b/.brightsec/tests/post-api-metadata.test.ts @@ -0,0 +1,36 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('POST /api/metadata', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['xxe', 'xss', 'secret_tokens'], + attackParamLocations: [AttackParamLocation.BODY, AttackParamLocation.HEADER], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.POST, + url: `${baseUrl}/api/metadata`, + body: `\u003csvg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" viewBox=\"0 0 915 585\"\u003e\u003cg stroke-width=\"3.45\" fill=\"none\"\u003e\u003cpath stroke=\"#000\" d=\"M11.8 11.8h411v411l-411 .01v-411z\"/\u003e\u003cpath stroke=\"#448\" d=\"M489 11.7h415v411H489v-411z\"/\u003e\u003c/g\u003e\u003c/svg\u003e`, + headers: { 'Content-Type': 'text/xml' } + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/post-api-render.test.ts b/.brightsec/tests/post-api-render.test.ts new file mode 100644 index 00000000..4a4e0166 --- /dev/null +++ b/.brightsec/tests/post-api-render.test.ts @@ -0,0 +1,36 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('POST /api/render', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['ssti', 'xss', 'osi'], + attackParamLocations: [AttackParamLocation.BODY], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.POST, + url: `${baseUrl}/api/render`, + body: "Write your text here", + headers: { 'Content-Type': 'text/plain' } + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/post-api-subscriptions.test.ts b/.brightsec/tests/post-api-subscriptions.test.ts new file mode 100644 index 00000000..dba4ae20 --- /dev/null +++ b/.brightsec/tests/post-api-subscriptions.test.ts @@ -0,0 +1,34 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('POST /api/subscriptions', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['csrf', 'email_injection', 'stored_xss', 'xss'], + attackParamLocations: [AttackParamLocation.QUERY], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.POST, + url: `${baseUrl}/api/subscriptions?email=john.doe@example.com` + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/post-api-users-basic.test.ts b/.brightsec/tests/post-api-users-basic.test.ts new file mode 100644 index 00000000..84162da4 --- /dev/null +++ b/.brightsec/tests/post-api-users-basic.test.ts @@ -0,0 +1,45 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('POST /api/users/basic', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['csrf', 'bopla', 'sqli', 'xss', 'email_injection', 'secret_tokens'], + attackParamLocations: [AttackParamLocation.BODY], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.POST, + url: `${baseUrl}/api/users/basic`, + body: { + email: 'john.doe@example.com', + firstName: 'John', + lastName: 'Doe', + company: 'Example Corp', + cardNumber: '1234-5678-9012-3456', + phoneNumber: '+1234567890', + password: 'securePassword123', + op: 'basic' + }, + headers: { 'Content-Type': 'application/json' } + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/post-api-users-oidc.test.ts b/.brightsec/tests/post-api-users-oidc.test.ts new file mode 100644 index 00000000..9e619694 --- /dev/null +++ b/.brightsec/tests/post-api-users-oidc.test.ts @@ -0,0 +1,46 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('POST /api/users/oidc', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['csrf', 'bopla', 'sqli', 'xss', 'secret_tokens', 'ldapi'], + attackParamLocations: [AttackParamLocation.BODY], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.POST, + url: `${baseUrl}/api/users/oidc`, + body: { + email: 'john.doe@example.com', + firstName: 'John', + lastName: 'Doe', + company: 'Dull Security', + id: 1, + cardNumber: '4263982640269299', + phoneNumber: '12065550100', + password: 'Pa55w0rd', + op: 'oidc' + }, + headers: { 'Content-Type': 'application/json' } + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/post-graphql-all-testimonials.test.ts b/.brightsec/tests/post-graphql-all-testimonials.test.ts new file mode 100644 index 00000000..3f38a8b3 --- /dev/null +++ b/.brightsec/tests/post-graphql-all-testimonials.test.ts @@ -0,0 +1,38 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('POST /graphql allTestimonials', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['graphql_introspection', 'bopla', 'sqli', 'xss', 'jwt'], + attackParamLocations: [AttackParamLocation.BODY], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.POST, + url: `${baseUrl}/graphql`, + body: { + query: "query { allTestimonials { name title message } }" + }, + headers: { 'Content-Type': 'application/json' } + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/post-graphql-get-command-result.test.ts b/.brightsec/tests/post-graphql-get-command-result.test.ts new file mode 100644 index 00000000..0c2dc942 --- /dev/null +++ b/.brightsec/tests/post-graphql-get-command-result.test.ts @@ -0,0 +1,39 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('POST /graphql getCommandResult', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['osi', 'graphql_introspection', 'sqli', 'xss'], + attackParamLocations: [AttackParamLocation.BODY], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.POST, + url: `${baseUrl}/graphql`, + body: { + query: "query getCommandResult($command: String!) { getCommandResult(command: $command) }", + variables: { command: "ls" } + }, + headers: { 'Content-Type': 'application/json' } + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/post-graphql-latest-products.test.ts b/.brightsec/tests/post-graphql-latest-products.test.ts new file mode 100644 index 00000000..fea4dac9 --- /dev/null +++ b/.brightsec/tests/post-graphql-latest-products.test.ts @@ -0,0 +1,38 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('POST /graphql latestProducts', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['sqli', 'csrf', 'graphql_introspection', 'bopla', 'stored_xss'], + attackParamLocations: [AttackParamLocation.BODY], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.POST, + url: `${baseUrl}/graphql`, + body: { + query: `query latestProducts { latestProducts { name category photoUrl description viewsCount } }` + }, + headers: { 'Content-Type': 'application/json' } + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/post-graphql-testimonials-count.test.ts b/.brightsec/tests/post-graphql-testimonials-count.test.ts new file mode 100644 index 00000000..7cf9962f --- /dev/null +++ b/.brightsec/tests/post-graphql-testimonials-count.test.ts @@ -0,0 +1,39 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('POST /graphql testimonialsCount', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['sqli', 'csrf', 'graphql_introspection', 'xss'], + attackParamLocations: [AttackParamLocation.BODY], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.POST, + url: `${baseUrl}/graphql`, + body: { + query: "query testimonialsCount($query: String!) { testimonialsCount(query: $query) }", + variables: { query: "SELECT COUNT(*) FROM testimonials" } + }, + headers: { 'Content-Type': 'application/json' } + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/post-graphql-view-product.test.ts b/.brightsec/tests/post-graphql-view-product.test.ts new file mode 100644 index 00000000..e4184cf7 --- /dev/null +++ b/.brightsec/tests/post-graphql-view-product.test.ts @@ -0,0 +1,39 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('POST /graphql viewProduct', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['sqli', 'csrf', 'graphql_introspection', 'bopla'], + attackParamLocations: [AttackParamLocation.BODY], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.POST, + url: `${baseUrl}/graphql`, + body: { + query: "mutation viewProduct($productName: String!) { viewProduct(productName: $productName) }", + variables: { productName: "Sample Product" } + }, + headers: { 'Content-Type': 'application/json' } + }); +}); \ No newline at end of file diff --git a/.brightsec/tests/put-api-file-raw-path-some-path-to-file-png.test.ts b/.brightsec/tests/put-api-file-raw-path-some-path-to-file-png.test.ts new file mode 100644 index 00000000..3d94fdff --- /dev/null +++ b/.brightsec/tests/put-api-file-raw-path-some-path-to-file-png.test.ts @@ -0,0 +1,36 @@ +import { test, before, after } from 'node:test'; +import { SecRunner } from '@sectester/runner'; +import { AttackParamLocation, HttpMethod } from '@sectester/scan'; + +const timeout = 40 * 60 * 1000; +const baseUrl = process.env.BRIGHT_TARGET_URL!; + +let runner!: SecRunner; + +before(async () => { + runner = new SecRunner({ + hostname: process.env.BRIGHT_HOSTNAME!, + projectId: process.env.BRIGHT_PROJECT_ID! + }); + + await runner.init(); +}); + +after(() => runner.clear()); + +test('PUT /api/file/raw?path=some/path/to/file.png', { signal: AbortSignal.timeout(timeout) }, async () => { + await runner + .createScan({ + tests: ['file_upload', 'lfi', 'osi', 'ssrf', 'sqli', 'xss'], + attackParamLocations: [AttackParamLocation.QUERY, AttackParamLocation.BODY], + starMetadata: { databases: ['PostgreSQL'] } + }) + .setFailFast(false) + .timeout(timeout) + .run({ + method: HttpMethod.PUT, + url: `${baseUrl}/api/file/raw?path=some/path/to/file.png`, + body: "This is a sample raw file content.", + headers: { 'Content-Type': 'text/plain' } + }); +}); \ No newline at end of file From 869e49fddea08934e5e2ba48084bd6aa62961a3a Mon Sep 17 00:00:00 2001 From: "bram-star-app[bot]" <203639708+bram-star-app[bot]@users.noreply.github.com> Date: Wed, 3 Sep 2025 07:22:50 +0000 Subject: [PATCH 04/12] ci: add CI workflow to run e2e security tests --- .github/workflows/bright.yml | 69 +++++++++++++++++++ .../configure-bright-credentials/action.yaml | 53 ++++++++++++++ 2 files changed, 122 insertions(+) create mode 100644 .github/workflows/bright.yml create mode 100644 .github/workflows/composite/configure-bright-credentials/action.yaml diff --git a/.github/workflows/bright.yml b/.github/workflows/bright.yml new file mode 100644 index 00000000..ae1a1418 --- /dev/null +++ b/.github/workflows/bright.yml @@ -0,0 +1,69 @@ +name: Bright + +on: + pull_request: + branches: + - '**' + +permissions: + checks: write + contents: read + id-token: write + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js 18.x + uses: actions/setup-node@v4 + with: + node-version: 18.x + + - name: Install application dependencies + run: npm ci --no-audit + + - name: Start application + env: + CHAT_API_MAX_TOKENS: 200 + CHAT_API_MODEL: smollm:135m + CHAT_API_TOKEN: "" + CHAT_API_URL: http://ollama:11434/v1/chat/completions + KC_BOOTSTRAP_ADMIN_PASSWORD: Pa55w0rd + KC_BOOTSTRAP_ADMIN_USERNAME: admin + KC_DB: postgres + KC_DB_PASSWORD: password + KC_DB_URL: jdbc:postgresql://keycloak-db:5432/keycloak + KC_DB_USERNAME: keycloak + POSTGRES_DB: bc + POSTGRES_PASSWORD: bc + POSTGRES_USER: bc + URL: http://localhost:3000 + run: docker compose -f compose.local.yml up --wait + + - name: Verify application readiness + run: | + until nc -zv 127.0.0.1 3000; do + echo "Waiting for application to be ready..." + sleep 5 + done + + - name: Setup Node.js 22.x + uses: actions/setup-node@v4 + with: + node-version: 22.x + + - name: Install SecTesterJS dependencies + run: npm i --save=false --prefix .brightsec @sectester/core @sectester/repeater @sectester/scan @sectester/runner @sectester/reporter + + - name: Run security tests + env: + BRIGHT_HOSTNAME: ${{ vars.BRIGHT_HOSTNAME }} + BRIGHT_PROJECT_ID: ${{ vars.BRIGHT_PROJECT_ID }} + BRIGHT_AUTH_ID: ${{ vars.BRIGHT_AUTH_ID }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRIGHT_TOKEN: ${{ secrets.BRIGHT_TOKEN }} + BRIGHT_TARGET_URL: http://127.0.0.1:3000 + run: node --experimental-transform-types --experimental-strip-types --experimental-detect-module --disable-warning=MODULE_TYPELESS_PACKAGE_JSON --disable-warning=ExperimentalWarning --test-force-exit --test-concurrency=4 --test .brightsec/tests/*.test.ts \ No newline at end of file diff --git a/.github/workflows/composite/configure-bright-credentials/action.yaml b/.github/workflows/composite/configure-bright-credentials/action.yaml new file mode 100644 index 00000000..84983846 --- /dev/null +++ b/.github/workflows/composite/configure-bright-credentials/action.yaml @@ -0,0 +1,53 @@ +name: 'Configure BrightSec credentials' + +inputs: + BRIGHT_HOSTNAME: + description: 'Hostname for the BrightSec environment' + required: true + BRIGHT_PROJECT_ID: + description: 'Project ID for BrightSec' + required: true + BRIGHT_TOKEN: + description: 'Pre-configured token' + required: false + +runs: + using: 'composite' + steps: + - id: configure_env_from_input + name: 'Set existing token in env' + shell: bash + if: ${{ inputs.BRIGHT_TOKEN != '' }} + env: + BRIGHT_TOKEN: ${{ inputs.BRIGHT_TOKEN }} + run: | + echo "BRIGHT_TOKEN=${BRIGHT_TOKEN}" >> $GITHUB_ENV + + - id: configure_bright_credentials_through_oidc + name: 'Exchange OIDC credentials for Bright token' + shell: bash + if: ${{ inputs.BRIGHT_TOKEN == '' }} + env: + BRIGHT_HOSTNAME: ${{ inputs.BRIGHT_HOSTNAME }} + BRIGHT_PROJECT_ID: ${{ inputs.BRIGHT_PROJECT_ID }} + run: | + # Retrieve OIDC token from GitHub + OIDC_TOKEN=$(curl -sS -H "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \ + "${ACTIONS_ID_TOKEN_REQUEST_URL}" | jq -r '.value') + + # Post the token to BrightSec + RESPONSE=$(curl -s -X POST "https://${BRIGHT_HOSTNAME}/api/v1/projects/${BRIGHT_PROJECT_ID}/api-keys/oidc" \ + -H "Content-Type: application/json" \ + -d "{\"token\": \"${OIDC_TOKEN}\"}") + + if ! echo "$RESPONSE" | jq -e . > /dev/null 2>&1; then + echo "Error: $RESPONSE" 1>&2 + exit 1 + fi + + # Extract the pureKey + PURE_KEY=$(echo "$RESPONSE" | jq -r '.pureKey') + + # Mask and store in environment + echo "::add-mask::$PURE_KEY" + echo "BRIGHT_TOKEN=$PURE_KEY" >> $GITHUB_ENV From 1acb218b4de831f884883025677e6ad4c5a2079e Mon Sep 17 00:00:00 2001 From: "bram-star-app[bot]" <203639708+bram-star-app[bot]@users.noreply.github.com> Date: Wed, 3 Sep 2025 07:55:44 +0000 Subject: [PATCH 05/12] test: remove completed test files that are no longer relevant skip-checks:true --- .../delete-api-email-delete-emails.test.ts | 34 -------------- ...ig-products-crystals-some-file-jpg.test.ts | 34 -------------- .../tests/get-api-auth-dom-csrf-flow.test.ts | 35 -------------- .../tests/get-api-auth-oidc-client.test.ts | 34 -------------- .../get-api-auth-simple-csrf-flow.test.ts | 34 -------------- .../tests/get-api-email-get-emails.test.ts | 34 -------------- .../get-api-email-send-support-email.test.ts | 35 -------------- ...fig-products-crystals-amethyst-jpg.test.ts | 35 -------------- .../tests/get-api-nestedjson-depth-2.test.ts | 35 -------------- .../tests/get-api-partners-query.test.ts | 35 -------------- .../tests/get-api-products-views.test.ts | 35 -------------- .../tests/get-api-spawn-command-ls-la.test.ts | 35 -------------- .../tests/get-api-testimonials-count.test.ts | 35 -------------- .brightsec/tests/get-api-testimonials.test.ts | 34 -------------- .../get-api-users-fullinfo-email.test.ts | 34 -------------- .brightsec/tests/get-api-users-ldap.test.ts | 34 -------------- .../tests/get-api-users-one-email.test.ts | 34 -------------- .../tests/get-api-users-search-john.test.ts | 34 -------------- .../tests/get-api-v1-userinfo-email.test.ts | 34 -------------- .../tests/get-graphql-command-ls.test.ts | 34 -------------- .brightsec/tests/options-api.test.ts | 35 -------------- .../tests/post-api-auth-admin-login.test.ts | 40 ---------------- .../post-api-auth-jwt-hmac-login.test.ts | 40 ---------------- .../tests/post-api-auth-jwt-jku-login.test.ts | 40 ---------------- .../tests/post-api-auth-jwt-jwk-login.test.ts | 40 ---------------- .../post-api-auth-jwt-kid-sql-login.test.ts | 43 ----------------- .../post-api-auth-jwt-weak-key-login.test.ts | 40 ---------------- .../tests/post-api-auth-jwt-x5c-login.test.ts | 40 ---------------- .../tests/post-api-auth-jwt-x5u-login.test.ts | 43 ----------------- .brightsec/tests/post-api-auth-login.test.ts | 43 ----------------- .brightsec/tests/post-api-chat-query.test.ts | 36 --------------- .brightsec/tests/post-api-metadata.test.ts | 36 --------------- .../tests/post-api-subscriptions.test.ts | 34 -------------- .brightsec/tests/post-api-users-basic.test.ts | 45 ------------------ .brightsec/tests/post-api-users-oidc.test.ts | 46 ------------------- .../post-graphql-all-testimonials.test.ts | 38 --------------- .../post-graphql-latest-products.test.ts | 38 --------------- .../post-graphql-testimonials-count.test.ts | 39 ---------------- ...ile-raw-path-some-path-to-file-png.test.ts | 36 --------------- 39 files changed, 1440 deletions(-) delete mode 100644 .brightsec/tests/delete-api-email-delete-emails.test.ts delete mode 100644 .brightsec/tests/delete-api-file-path-config-products-crystals-some-file-jpg.test.ts delete mode 100644 .brightsec/tests/get-api-auth-dom-csrf-flow.test.ts delete mode 100644 .brightsec/tests/get-api-auth-oidc-client.test.ts delete mode 100644 .brightsec/tests/get-api-auth-simple-csrf-flow.test.ts delete mode 100644 .brightsec/tests/get-api-email-get-emails.test.ts delete mode 100644 .brightsec/tests/get-api-email-send-support-email.test.ts delete mode 100644 .brightsec/tests/get-api-file-raw-path-config-products-crystals-amethyst-jpg.test.ts delete mode 100644 .brightsec/tests/get-api-nestedjson-depth-2.test.ts delete mode 100644 .brightsec/tests/get-api-partners-query.test.ts delete mode 100644 .brightsec/tests/get-api-products-views.test.ts delete mode 100644 .brightsec/tests/get-api-spawn-command-ls-la.test.ts delete mode 100644 .brightsec/tests/get-api-testimonials-count.test.ts delete mode 100644 .brightsec/tests/get-api-testimonials.test.ts delete mode 100644 .brightsec/tests/get-api-users-fullinfo-email.test.ts delete mode 100644 .brightsec/tests/get-api-users-ldap.test.ts delete mode 100644 .brightsec/tests/get-api-users-one-email.test.ts delete mode 100644 .brightsec/tests/get-api-users-search-john.test.ts delete mode 100644 .brightsec/tests/get-api-v1-userinfo-email.test.ts delete mode 100644 .brightsec/tests/get-graphql-command-ls.test.ts delete mode 100644 .brightsec/tests/options-api.test.ts delete mode 100644 .brightsec/tests/post-api-auth-admin-login.test.ts delete mode 100644 .brightsec/tests/post-api-auth-jwt-hmac-login.test.ts delete mode 100644 .brightsec/tests/post-api-auth-jwt-jku-login.test.ts delete mode 100644 .brightsec/tests/post-api-auth-jwt-jwk-login.test.ts delete mode 100644 .brightsec/tests/post-api-auth-jwt-kid-sql-login.test.ts delete mode 100644 .brightsec/tests/post-api-auth-jwt-weak-key-login.test.ts delete mode 100644 .brightsec/tests/post-api-auth-jwt-x5c-login.test.ts delete mode 100644 .brightsec/tests/post-api-auth-jwt-x5u-login.test.ts delete mode 100644 .brightsec/tests/post-api-auth-login.test.ts delete mode 100644 .brightsec/tests/post-api-chat-query.test.ts delete mode 100644 .brightsec/tests/post-api-metadata.test.ts delete mode 100644 .brightsec/tests/post-api-subscriptions.test.ts delete mode 100644 .brightsec/tests/post-api-users-basic.test.ts delete mode 100644 .brightsec/tests/post-api-users-oidc.test.ts delete mode 100644 .brightsec/tests/post-graphql-all-testimonials.test.ts delete mode 100644 .brightsec/tests/post-graphql-latest-products.test.ts delete mode 100644 .brightsec/tests/post-graphql-testimonials-count.test.ts delete mode 100644 .brightsec/tests/put-api-file-raw-path-some-path-to-file-png.test.ts diff --git a/.brightsec/tests/delete-api-email-delete-emails.test.ts b/.brightsec/tests/delete-api-email-delete-emails.test.ts deleted file mode 100644 index 8deb0722..00000000 --- a/.brightsec/tests/delete-api-email-delete-emails.test.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('DELETE /api/email/deleteEmails', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['csrf', 'bopla', 'improper_asset_management'], - attackParamLocations: [AttackParamLocation.PATH], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.DELETE, - url: `${baseUrl}/api/email/deleteEmails` - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/delete-api-file-path-config-products-crystals-some-file-jpg.test.ts b/.brightsec/tests/delete-api-file-path-config-products-crystals-some-file-jpg.test.ts deleted file mode 100644 index 1e2439f4..00000000 --- a/.brightsec/tests/delete-api-file-path-config-products-crystals-some-file-jpg.test.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('DELETE /api/file?path=config/products/crystals/some_file.jpg', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['lfi', 'ssrf', 'bopla', 'sqli', 'csrf'], - attackParamLocations: [AttackParamLocation.QUERY], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.DELETE, - url: `${baseUrl}/api/file?path=config/products/crystals/some_file.jpg` - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-auth-dom-csrf-flow.test.ts b/.brightsec/tests/get-api-auth-dom-csrf-flow.test.ts deleted file mode 100644 index ea277550..00000000 --- a/.brightsec/tests/get-api-auth-dom-csrf-flow.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('GET /api/auth/dom-csrf-flow', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['csrf', 'xss', 'full_path_disclosure'], - attackParamLocations: [AttackParamLocation.HEADER], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.GET, - url: `${baseUrl}/api/auth/dom-csrf-flow`, - headers: { fingerprint: 'example-fingerprint' } - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-auth-oidc-client.test.ts b/.brightsec/tests/get-api-auth-oidc-client.test.ts deleted file mode 100644 index dfca392d..00000000 --- a/.brightsec/tests/get-api-auth-oidc-client.test.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('GET /api/auth/oidc-client', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['csrf', 'secret_tokens', 'open_database', 'xss'], - attackParamLocations: [AttackParamLocation.HEADER, AttackParamLocation.PATH, AttackParamLocation.QUERY], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.GET, - url: `${baseUrl}/api/auth/oidc-client` - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-auth-simple-csrf-flow.test.ts b/.brightsec/tests/get-api-auth-simple-csrf-flow.test.ts deleted file mode 100644 index 0c7e6990..00000000 --- a/.brightsec/tests/get-api-auth-simple-csrf-flow.test.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('GET /api/auth/simple-csrf-flow', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['csrf', 'xss', 'secret_tokens'], - attackParamLocations: [AttackParamLocation.HEADER, AttackParamLocation.PATH], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.GET, - url: `${baseUrl}/api/auth/simple-csrf-flow` - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-email-get-emails.test.ts b/.brightsec/tests/get-api-email-get-emails.test.ts deleted file mode 100644 index f7512b6a..00000000 --- a/.brightsec/tests/get-api-email-get-emails.test.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('GET /api/email/getEmails?withSource=true', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['proto_pollution', 'business_constraint_bypass', 'csrf', 'xss'], - attackParamLocations: [AttackParamLocation.QUERY], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.GET, - url: `${baseUrl}/api/email/getEmails?withSource=true` - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-email-send-support-email.test.ts b/.brightsec/tests/get-api-email-send-support-email.test.ts deleted file mode 100644 index cd09d91f..00000000 --- a/.brightsec/tests/get-api-email-send-support-email.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('GET /api/email/sendSupportEmail', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['proto_pollution', 'email_injection', 'xss'], - attackParamLocations: [AttackParamLocation.QUERY], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.GET, - url: `${baseUrl}/api/email/sendSupportEmail?name=Bob%20Dylan&to=username%40email.com&subject=Help%20Request&content=I%20would%20like%20to%20request%20help%20regarding..`, - headers: { 'Content-Type': 'application/json' } - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-file-raw-path-config-products-crystals-amethyst-jpg.test.ts b/.brightsec/tests/get-api-file-raw-path-config-products-crystals-amethyst-jpg.test.ts deleted file mode 100644 index ba789047..00000000 --- a/.brightsec/tests/get-api-file-raw-path-config-products-crystals-amethyst-jpg.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('GET /api/file/raw?path=config/products/crystals/amethyst.jpg', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['lfi', 'ssrf', 'full_path_disclosure', 'open_cloud_storage'], - attackParamLocations: [AttackParamLocation.QUERY], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.GET, - url: `${baseUrl}/api/file/raw?path=config/products/crystals/amethyst.jpg`, - headers: { accept: 'image/jpg' } - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-nestedjson-depth-2.test.ts b/.brightsec/tests/get-api-nestedjson-depth-2.test.ts deleted file mode 100644 index 650e1fb2..00000000 --- a/.brightsec/tests/get-api-nestedjson-depth-2.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('GET /api/nestedJson?depth=2', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['business_constraint_bypass', 'osi', 'xss'], - attackParamLocations: [AttackParamLocation.QUERY], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.GET, - url: `${baseUrl}/api/nestedJson?depth=2`, - headers: { 'Content-Type': 'application/json' } - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-partners-query.test.ts b/.brightsec/tests/get-api-partners-query.test.ts deleted file mode 100644 index c9d9d3d2..00000000 --- a/.brightsec/tests/get-api-partners-query.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('GET /api/partners/query', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['xpathi', 'xss', 'full_path_disclosure'], - attackParamLocations: [AttackParamLocation.QUERY], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.GET, - url: `${baseUrl}/api/partners/query?xpath=%2Fpartners%2Fpartner%2Fname`, - headers: { 'Content-Type': 'text/xml' } - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-products-views.test.ts b/.brightsec/tests/get-api-products-views.test.ts deleted file mode 100644 index cdd65d02..00000000 --- a/.brightsec/tests/get-api-products-views.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('GET /api/products/views', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['sqli', 'xss', 'csrf', 'business_constraint_bypass', 'full_path_disclosure'], - attackParamLocations: [AttackParamLocation.HEADER], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.GET, - url: `${baseUrl}/api/products/views`, - headers: { 'x-product-name': 'Amethyst' } - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-spawn-command-ls-la.test.ts b/.brightsec/tests/get-api-spawn-command-ls-la.test.ts deleted file mode 100644 index 1bab8cbc..00000000 --- a/.brightsec/tests/get-api-spawn-command-ls-la.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('GET /api/spawn?command=ls-la', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['osi', 'full_path_disclosure', 'secret_tokens'], - attackParamLocations: [AttackParamLocation.QUERY], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.GET, - url: `${baseUrl}/api/spawn?command=ls%20-la`, - headers: { allow: 'OPTIONS, GET, HEAD, POST' } - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-testimonials-count.test.ts b/.brightsec/tests/get-api-testimonials-count.test.ts deleted file mode 100644 index 8b20c8c2..00000000 --- a/.brightsec/tests/get-api-testimonials-count.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('GET /api/testimonials/count', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['sqli', 'full_path_disclosure', 'business_constraint_bypass'], - attackParamLocations: [AttackParamLocation.QUERY], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.GET, - url: `${baseUrl}/api/testimonials/count?query=select%20count(*)%20as%20count%20from%20testimonial`, - headers: { 'Content-Type': 'text/html' } - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-testimonials.test.ts b/.brightsec/tests/get-api-testimonials.test.ts deleted file mode 100644 index 44e5d7fb..00000000 --- a/.brightsec/tests/get-api-testimonials.test.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('GET /api/testimonials', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['sqli', 'csrf', 'xss', 'business_constraint_bypass'], - attackParamLocations: [AttackParamLocation.QUERY, AttackParamLocation.HEADER], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.GET, - url: `${baseUrl}/api/testimonials` - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-users-fullinfo-email.test.ts b/.brightsec/tests/get-api-users-fullinfo-email.test.ts deleted file mode 100644 index 653e771f..00000000 --- a/.brightsec/tests/get-api-users-fullinfo-email.test.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('GET /api/users/fullinfo/:email', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['bopla', 'id_enumeration', 'xss', 'sqli', 'csrf'], - attackParamLocations: [AttackParamLocation.PATH], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.GET, - url: `${baseUrl}/api/users/fullinfo/john.doe@example.com` - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-users-ldap.test.ts b/.brightsec/tests/get-api-users-ldap.test.ts deleted file mode 100644 index 13eba27a..00000000 --- a/.brightsec/tests/get-api-users-ldap.test.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('GET /api/users/ldap', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['ldapi', 'xss', 'full_path_disclosure'], - attackParamLocations: [AttackParamLocation.QUERY], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.GET, - url: `${baseUrl}/api/users/ldap?query=%28%26%28objectClass%3Dperson%29%28objectClass%3Duser%29%28email%3Djohn.doe%40example.com%29%29` - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-users-one-email.test.ts b/.brightsec/tests/get-api-users-one-email.test.ts deleted file mode 100644 index a80bdf71..00000000 --- a/.brightsec/tests/get-api-users-one-email.test.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('GET /api/users/one/:email', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['bopla', 'csrf', 'email_injection', 'id_enumeration', 'jwt', 'xss'], - attackParamLocations: [AttackParamLocation.PATH], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.GET, - url: `${baseUrl}/api/users/one/john.doe@example.com` - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-users-search-john.test.ts b/.brightsec/tests/get-api-users-search-john.test.ts deleted file mode 100644 index 1747b1e8..00000000 --- a/.brightsec/tests/get-api-users-search-john.test.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('GET /api/users/search/john', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['sqli', 'xss', 'id_enumeration', 'business_constraint_bypass'], - attackParamLocations: [AttackParamLocation.PATH], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.GET, - url: `${baseUrl}/api/users/search/john` - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-v1-userinfo-email.test.ts b/.brightsec/tests/get-api-v1-userinfo-email.test.ts deleted file mode 100644 index 03a8bc5d..00000000 --- a/.brightsec/tests/get-api-v1-userinfo-email.test.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('GET /api/v1/userinfo/:email', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['id_enumeration', 'xss', 'bopla', 'csrf', 'secret_tokens'], - attackParamLocations: [AttackParamLocation.PATH], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.GET, - url: `${baseUrl}/api/v1/userinfo/john.doe@example.com` - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/get-graphql-command-ls.test.ts b/.brightsec/tests/get-graphql-command-ls.test.ts deleted file mode 100644 index 7c8cad23..00000000 --- a/.brightsec/tests/get-graphql-command-ls.test.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('GET /graphql?command=ls', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['osi', 'graphql_introspection', 'xss', 'ssrf'], - attackParamLocations: [AttackParamLocation.QUERY], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.GET, - url: `${baseUrl}/graphql?command=ls` - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/options-api.test.ts b/.brightsec/tests/options-api.test.ts deleted file mode 100644 index 200567cf..00000000 --- a/.brightsec/tests/options-api.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('OPTIONS /api', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['http_method_fuzzing', 'csrf'], - attackParamLocations: [AttackParamLocation.HEADER], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.OPTIONS, - url: `${baseUrl}/api`, - headers: { allow: 'OPTIONS, GET, HEAD, POST' } - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/post-api-auth-admin-login.test.ts b/.brightsec/tests/post-api-auth-admin-login.test.ts deleted file mode 100644 index d3718e92..00000000 --- a/.brightsec/tests/post-api-auth-admin-login.test.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('POST /api/auth/admin/login', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['csrf', 'jwt', 'sqli', 'osi', 'unvalidated_redirect'], - attackParamLocations: [AttackParamLocation.BODY], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.POST, - url: `${baseUrl}/api/auth/admin/login`, - body: { - user: 'john', - password: 'Pa55w0rd', - op: 'basic' - }, - headers: { 'Content-Type': 'application/json' } - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/post-api-auth-jwt-hmac-login.test.ts b/.brightsec/tests/post-api-auth-jwt-hmac-login.test.ts deleted file mode 100644 index 11c02ee4..00000000 --- a/.brightsec/tests/post-api-auth-jwt-hmac-login.test.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('POST /api/auth/jwt/hmac/login', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['csrf', 'jwt', 'sqli', 'osi', 'xss'], - attackParamLocations: [AttackParamLocation.BODY], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.POST, - url: `${baseUrl}/api/auth/jwt/hmac/login`, - body: { - user: 'john', - password: 'Pa55w0rd', - op: 'basic' - }, - headers: { 'Content-Type': 'application/json' } - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/post-api-auth-jwt-jku-login.test.ts b/.brightsec/tests/post-api-auth-jwt-jku-login.test.ts deleted file mode 100644 index 81330bbc..00000000 --- a/.brightsec/tests/post-api-auth-jwt-jku-login.test.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('POST /api/auth/jwt/jku/login', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['jwt', 'csrf', 'sqli', 'osi', 'unvalidated_redirect'], - attackParamLocations: [AttackParamLocation.BODY], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.POST, - url: `${baseUrl}/api/auth/jwt/jku/login`, - body: { - user: 'john', - password: 'Pa55w0rd', - op: 'basic' - }, - headers: { 'Content-Type': 'application/json' } - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/post-api-auth-jwt-jwk-login.test.ts b/.brightsec/tests/post-api-auth-jwt-jwk-login.test.ts deleted file mode 100644 index 3f5a36f3..00000000 --- a/.brightsec/tests/post-api-auth-jwt-jwk-login.test.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('POST /api/auth/jwt/jwk/login', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['jwt', 'csrf', 'sqli', 'osi', 'xss'], - attackParamLocations: [AttackParamLocation.BODY], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.POST, - url: `${baseUrl}/api/auth/jwt/jwk/login`, - body: { - user: 'john', - password: 'Pa55w0rd', - op: 'basic' - }, - headers: { 'Content-Type': 'application/json' } - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/post-api-auth-jwt-kid-sql-login.test.ts b/.brightsec/tests/post-api-auth-jwt-kid-sql-login.test.ts deleted file mode 100644 index f7366ed9..00000000 --- a/.brightsec/tests/post-api-auth-jwt-kid-sql-login.test.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('POST /api/auth/jwt/kid-sql/login', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['sqli', 'jwt', 'csrf', 'xss', 'osi'], - attackParamLocations: [AttackParamLocation.BODY, AttackParamLocation.HEADER], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.POST, - url: `${baseUrl}/api/auth/jwt/kid-sql/login`, - body: { - user: 'john', - password: 'Pa55w0rd', - op: 'basic' - }, - headers: { - 'Content-Type': 'application/json', - 'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjoiam9obkBleGFtcGxlLmNvbSIsImV4cCI6MTYwOTI3MzYwMH0.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c' - } - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/post-api-auth-jwt-weak-key-login.test.ts b/.brightsec/tests/post-api-auth-jwt-weak-key-login.test.ts deleted file mode 100644 index a4dea4f4..00000000 --- a/.brightsec/tests/post-api-auth-jwt-weak-key-login.test.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('POST /api/auth/jwt/weak-key/login', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['jwt', 'csrf', 'sqli', 'secret_tokens'], - attackParamLocations: [AttackParamLocation.BODY], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.POST, - url: `${baseUrl}/api/auth/jwt/weak-key/login`, - body: { - user: 'john', - password: 'Pa55w0rd', - op: 'basic' - }, - headers: { 'Content-Type': 'application/json' } - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/post-api-auth-jwt-x5c-login.test.ts b/.brightsec/tests/post-api-auth-jwt-x5c-login.test.ts deleted file mode 100644 index 734ce0d4..00000000 --- a/.brightsec/tests/post-api-auth-jwt-x5c-login.test.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('POST /api/auth/jwt/x5c/login', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['jwt', 'csrf', 'sqli', 'osi', 'secret_tokens'], - attackParamLocations: [AttackParamLocation.BODY], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.POST, - url: `${baseUrl}/api/auth/jwt/x5c/login`, - body: { - user: 'john', - password: 'Pa55w0rd', - op: 'basic' - }, - headers: { 'Content-Type': 'application/json' } - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/post-api-auth-jwt-x5u-login.test.ts b/.brightsec/tests/post-api-auth-jwt-x5u-login.test.ts deleted file mode 100644 index e984c52c..00000000 --- a/.brightsec/tests/post-api-auth-jwt-x5u-login.test.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('POST /api/auth/jwt/x5u/login', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['jwt', 'csrf', 'sqli', 'bopla', 'osi'], - attackParamLocations: [AttackParamLocation.BODY, AttackParamLocation.HEADER], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.POST, - url: `${baseUrl}/api/auth/jwt/x5u/login`, - body: { - user: 'john', - password: 'Pa55w0rd', - op: 'basic' - }, - headers: { - 'Content-Type': 'application/json', - Authorization: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjoiam9obkBleGFtcGxlLmNvbSIsImV4cCI6MTYwOTI3MzYwMH0.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c' - } - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/post-api-auth-login.test.ts b/.brightsec/tests/post-api-auth-login.test.ts deleted file mode 100644 index 82d2f549..00000000 --- a/.brightsec/tests/post-api-auth-login.test.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('POST /api/auth/login', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['csrf', 'jwt', 'sqli', 'bopla', 'osi', 'xss'], - attackParamLocations: [AttackParamLocation.BODY, AttackParamLocation.HEADER], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.POST, - url: `${baseUrl}/api/auth/login`, - body: { - user: 'john', - password: 'Pa55w0rd', - op: 'basic' - }, - headers: { - 'Content-Type': 'application/json', - 'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c' - } - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/post-api-chat-query.test.ts b/.brightsec/tests/post-api-chat-query.test.ts deleted file mode 100644 index 4c7207b7..00000000 --- a/.brightsec/tests/post-api-chat-query.test.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('POST /api/chat/query', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['csrf', 'prompt_injection', 'secret_tokens', 'server_side_js_injection', 'ssrf'], - attackParamLocations: [AttackParamLocation.BODY], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.POST, - url: `${baseUrl}/api/chat/query`, - body: [{ role: 'user', content: 'Hello, how are you?' }], - headers: { 'Content-Type': 'application/json' } - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/post-api-metadata.test.ts b/.brightsec/tests/post-api-metadata.test.ts deleted file mode 100644 index c0d1e538..00000000 --- a/.brightsec/tests/post-api-metadata.test.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('POST /api/metadata', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['xxe', 'xss', 'secret_tokens'], - attackParamLocations: [AttackParamLocation.BODY, AttackParamLocation.HEADER], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.POST, - url: `${baseUrl}/api/metadata`, - body: `\u003csvg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" viewBox=\"0 0 915 585\"\u003e\u003cg stroke-width=\"3.45\" fill=\"none\"\u003e\u003cpath stroke=\"#000\" d=\"M11.8 11.8h411v411l-411 .01v-411z\"/\u003e\u003cpath stroke=\"#448\" d=\"M489 11.7h415v411H489v-411z\"/\u003e\u003c/g\u003e\u003c/svg\u003e`, - headers: { 'Content-Type': 'text/xml' } - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/post-api-subscriptions.test.ts b/.brightsec/tests/post-api-subscriptions.test.ts deleted file mode 100644 index dba4ae20..00000000 --- a/.brightsec/tests/post-api-subscriptions.test.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('POST /api/subscriptions', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['csrf', 'email_injection', 'stored_xss', 'xss'], - attackParamLocations: [AttackParamLocation.QUERY], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.POST, - url: `${baseUrl}/api/subscriptions?email=john.doe@example.com` - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/post-api-users-basic.test.ts b/.brightsec/tests/post-api-users-basic.test.ts deleted file mode 100644 index 84162da4..00000000 --- a/.brightsec/tests/post-api-users-basic.test.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('POST /api/users/basic', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['csrf', 'bopla', 'sqli', 'xss', 'email_injection', 'secret_tokens'], - attackParamLocations: [AttackParamLocation.BODY], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.POST, - url: `${baseUrl}/api/users/basic`, - body: { - email: 'john.doe@example.com', - firstName: 'John', - lastName: 'Doe', - company: 'Example Corp', - cardNumber: '1234-5678-9012-3456', - phoneNumber: '+1234567890', - password: 'securePassword123', - op: 'basic' - }, - headers: { 'Content-Type': 'application/json' } - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/post-api-users-oidc.test.ts b/.brightsec/tests/post-api-users-oidc.test.ts deleted file mode 100644 index 9e619694..00000000 --- a/.brightsec/tests/post-api-users-oidc.test.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('POST /api/users/oidc', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['csrf', 'bopla', 'sqli', 'xss', 'secret_tokens', 'ldapi'], - attackParamLocations: [AttackParamLocation.BODY], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.POST, - url: `${baseUrl}/api/users/oidc`, - body: { - email: 'john.doe@example.com', - firstName: 'John', - lastName: 'Doe', - company: 'Dull Security', - id: 1, - cardNumber: '4263982640269299', - phoneNumber: '12065550100', - password: 'Pa55w0rd', - op: 'oidc' - }, - headers: { 'Content-Type': 'application/json' } - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/post-graphql-all-testimonials.test.ts b/.brightsec/tests/post-graphql-all-testimonials.test.ts deleted file mode 100644 index 3f38a8b3..00000000 --- a/.brightsec/tests/post-graphql-all-testimonials.test.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('POST /graphql allTestimonials', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['graphql_introspection', 'bopla', 'sqli', 'xss', 'jwt'], - attackParamLocations: [AttackParamLocation.BODY], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.POST, - url: `${baseUrl}/graphql`, - body: { - query: "query { allTestimonials { name title message } }" - }, - headers: { 'Content-Type': 'application/json' } - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/post-graphql-latest-products.test.ts b/.brightsec/tests/post-graphql-latest-products.test.ts deleted file mode 100644 index fea4dac9..00000000 --- a/.brightsec/tests/post-graphql-latest-products.test.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('POST /graphql latestProducts', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['sqli', 'csrf', 'graphql_introspection', 'bopla', 'stored_xss'], - attackParamLocations: [AttackParamLocation.BODY], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.POST, - url: `${baseUrl}/graphql`, - body: { - query: `query latestProducts { latestProducts { name category photoUrl description viewsCount } }` - }, - headers: { 'Content-Type': 'application/json' } - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/post-graphql-testimonials-count.test.ts b/.brightsec/tests/post-graphql-testimonials-count.test.ts deleted file mode 100644 index 7cf9962f..00000000 --- a/.brightsec/tests/post-graphql-testimonials-count.test.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('POST /graphql testimonialsCount', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['sqli', 'csrf', 'graphql_introspection', 'xss'], - attackParamLocations: [AttackParamLocation.BODY], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.POST, - url: `${baseUrl}/graphql`, - body: { - query: "query testimonialsCount($query: String!) { testimonialsCount(query: $query) }", - variables: { query: "SELECT COUNT(*) FROM testimonials" } - }, - headers: { 'Content-Type': 'application/json' } - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/put-api-file-raw-path-some-path-to-file-png.test.ts b/.brightsec/tests/put-api-file-raw-path-some-path-to-file-png.test.ts deleted file mode 100644 index 3d94fdff..00000000 --- a/.brightsec/tests/put-api-file-raw-path-some-path-to-file-png.test.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('PUT /api/file/raw?path=some/path/to/file.png', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['file_upload', 'lfi', 'osi', 'ssrf', 'sqli', 'xss'], - attackParamLocations: [AttackParamLocation.QUERY, AttackParamLocation.BODY], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.PUT, - url: `${baseUrl}/api/file/raw?path=some/path/to/file.png`, - body: "This is a sample raw file content.", - headers: { 'Content-Type': 'text/plain' } - }); -}); \ No newline at end of file From 35ff5b9867b017fbb5fbddca151434135331f619 Mon Sep 17 00:00:00 2001 From: "bram-star-app[bot]" <203639708+bram-star-app[bot]@users.noreply.github.com> Date: Wed, 3 Sep 2025 07:56:44 +0000 Subject: [PATCH 06/12] test: optimize security tests to focus on specific vulnerabilities skip-checks:true --- .brightsec/tests/get-api-file-aws.test.ts | 2 +- .brightsec/tests/get-api-file-azure.test.ts | 4 ++-- .brightsec/tests/get-api-file-digital-ocean.test.ts | 4 ++-- .brightsec/tests/get-api-file-google.test.ts | 4 ++-- ...nfig-products-crystals-amethyst-jpg-type-image-jpg.test.ts | 4 ++-- .brightsec/tests/get-api-goto.test.ts | 4 ++-- .brightsec/tests/get-api-partners-partner-login.test.ts | 4 ++-- .brightsec/tests/get-api-partners-search-partners.test.ts | 4 ++-- .brightsec/tests/get-api-products-latest.test.ts | 2 +- .brightsec/tests/get-api-secrets.test.ts | 4 ++-- .brightsec/tests/get-graphql.test.ts | 4 ++-- .brightsec/tests/post-api-render.test.ts | 4 ++-- .brightsec/tests/post-graphql-get-command-result.test.ts | 4 ++-- .brightsec/tests/post-graphql-view-product.test.ts | 4 ++-- 14 files changed, 26 insertions(+), 26 deletions(-) diff --git a/.brightsec/tests/get-api-file-aws.test.ts b/.brightsec/tests/get-api-file-aws.test.ts index 99409b6a..a6cde144 100644 --- a/.brightsec/tests/get-api-file-aws.test.ts +++ b/.brightsec/tests/get-api-file-aws.test.ts @@ -21,7 +21,7 @@ after(() => runner.clear()); test('GET /api/file/aws', { signal: AbortSignal.timeout(timeout) }, async () => { await runner .createScan({ - tests: ['amazon_s3_takeover', 'ssrf', 'lfi', 'open_cloud_storage', 'secret_tokens'], + tests: ['ssrf'], attackParamLocations: [AttackParamLocation.QUERY, AttackParamLocation.HEADER], starMetadata: { databases: ['PostgreSQL'] } }) diff --git a/.brightsec/tests/get-api-file-azure.test.ts b/.brightsec/tests/get-api-file-azure.test.ts index f865ec68..9e20e94c 100644 --- a/.brightsec/tests/get-api-file-azure.test.ts +++ b/.brightsec/tests/get-api-file-azure.test.ts @@ -21,7 +21,7 @@ after(() => runner.clear()); test('GET /api/file/azure', { signal: AbortSignal.timeout(timeout) }, async () => { await runner .createScan({ - tests: ['open_cloud_storage', 'lfi', 'ssrf', 'unvalidated_redirect'], + tests: ['ssrf'], attackParamLocations: [AttackParamLocation.QUERY, AttackParamLocation.HEADER], starMetadata: { databases: ['PostgreSQL'] } }) @@ -32,4 +32,4 @@ test('GET /api/file/azure', { signal: AbortSignal.timeout(timeout) }, async () = url: `${baseUrl}/api/file/azure?path=config/products/crystals/amethyst.jpg&type=image/jpg`, headers: { accept: 'image/jpg' } }); -}); \ No newline at end of file +}); diff --git a/.brightsec/tests/get-api-file-digital-ocean.test.ts b/.brightsec/tests/get-api-file-digital-ocean.test.ts index 91371977..b157a21f 100644 --- a/.brightsec/tests/get-api-file-digital-ocean.test.ts +++ b/.brightsec/tests/get-api-file-digital-ocean.test.ts @@ -21,7 +21,7 @@ after(() => runner.clear()); test('GET /api/file/digital_ocean', { signal: AbortSignal.timeout(timeout) }, async () => { await runner .createScan({ - tests: ['ssrf', 'lfi', 'open_cloud_storage', 'file_upload'], + tests: ['ssrf'], attackParamLocations: [AttackParamLocation.QUERY, AttackParamLocation.HEADER], starMetadata: { databases: ['PostgreSQL'] } }) @@ -32,4 +32,4 @@ test('GET /api/file/digital_ocean', { signal: AbortSignal.timeout(timeout) }, as url: `${baseUrl}/api/file/digital_ocean?path=config/products/crystals/amethyst.jpg&type=image/jpg`, headers: { accept: 'image/jpg' } }); -}); \ No newline at end of file +}); diff --git a/.brightsec/tests/get-api-file-google.test.ts b/.brightsec/tests/get-api-file-google.test.ts index 9342bb66..e1c73e8f 100644 --- a/.brightsec/tests/get-api-file-google.test.ts +++ b/.brightsec/tests/get-api-file-google.test.ts @@ -21,7 +21,7 @@ after(() => runner.clear()); test('GET /api/file/google', { signal: AbortSignal.timeout(timeout) }, async () => { await runner .createScan({ - tests: ['ssrf', 'lfi', 'open_cloud_storage', 'file_upload'], + tests: ['ssrf'], attackParamLocations: [AttackParamLocation.QUERY, AttackParamLocation.HEADER], starMetadata: { databases: ['PostgreSQL'] } }) @@ -32,4 +32,4 @@ test('GET /api/file/google', { signal: AbortSignal.timeout(timeout) }, async () url: `${baseUrl}/api/file/google?path=config/products/crystals/amethyst.jpg&type=image/jpg`, headers: { accept: 'image/jpg' } }); -}); \ No newline at end of file +}); diff --git a/.brightsec/tests/get-api-file-path-config-products-crystals-amethyst-jpg-type-image-jpg.test.ts b/.brightsec/tests/get-api-file-path-config-products-crystals-amethyst-jpg-type-image-jpg.test.ts index 575b01b6..e6ad6d66 100644 --- a/.brightsec/tests/get-api-file-path-config-products-crystals-amethyst-jpg-type-image-jpg.test.ts +++ b/.brightsec/tests/get-api-file-path-config-products-crystals-amethyst-jpg-type-image-jpg.test.ts @@ -21,7 +21,7 @@ after(() => runner.clear()); test('GET /api/file?path=config/products/crystals/amethyst.jpg&type=image/jpg', { signal: AbortSignal.timeout(timeout) }, async () => { await runner .createScan({ - tests: ['lfi', 'ssrf', 'open_cloud_storage', 'file_upload', 'full_path_disclosure'], + tests: ['ssrf', 'lfi', 'full_path_disclosure'], attackParamLocations: [AttackParamLocation.QUERY], starMetadata: { databases: ['PostgreSQL'] } }) @@ -32,4 +32,4 @@ test('GET /api/file?path=config/products/crystals/amethyst.jpg&type=image/jpg', url: `${baseUrl}/api/file?path=config/products/crystals/amethyst.jpg&type=image/jpg`, headers: { accept: 'image/jpg' } }); -}); \ No newline at end of file +}); diff --git a/.brightsec/tests/get-api-goto.test.ts b/.brightsec/tests/get-api-goto.test.ts index 32a30e02..0ef0b4bd 100644 --- a/.brightsec/tests/get-api-goto.test.ts +++ b/.brightsec/tests/get-api-goto.test.ts @@ -21,7 +21,7 @@ after(() => runner.clear()); test('GET /api/goto', { signal: AbortSignal.timeout(timeout) }, async () => { await runner .createScan({ - tests: ['unvalidated_redirect', 'ssrf'], + tests: ['unvalidated_redirect'], attackParamLocations: [AttackParamLocation.QUERY], starMetadata: { databases: ['PostgreSQL'] } }) @@ -31,4 +31,4 @@ test('GET /api/goto', { signal: AbortSignal.timeout(timeout) }, async () => { method: HttpMethod.GET, url: `${baseUrl}/api/goto?url=https://google.com` }); -}); \ No newline at end of file +}); diff --git a/.brightsec/tests/get-api-partners-partner-login.test.ts b/.brightsec/tests/get-api-partners-partner-login.test.ts index ff7366a1..e0ac578d 100644 --- a/.brightsec/tests/get-api-partners-partner-login.test.ts +++ b/.brightsec/tests/get-api-partners-partner-login.test.ts @@ -21,7 +21,7 @@ after(() => runner.clear()); test('GET /api/partners/partnerLogin', { signal: AbortSignal.timeout(timeout) }, async () => { await runner .createScan({ - tests: ['xpathi', 'xss', 'full_path_disclosure'], + tests: ['xpathi'], attackParamLocations: [AttackParamLocation.QUERY], starMetadata: { databases: ['PostgreSQL'] } }) @@ -32,4 +32,4 @@ test('GET /api/partners/partnerLogin', { signal: AbortSignal.timeout(timeout) }, url: `${baseUrl}/api/partners/partnerLogin?username=walter100&password=Heisenberg123`, headers: { 'Content-Type': 'text/xml' } }); -}); \ No newline at end of file +}); diff --git a/.brightsec/tests/get-api-partners-search-partners.test.ts b/.brightsec/tests/get-api-partners-search-partners.test.ts index 42447fb9..0aa6faee 100644 --- a/.brightsec/tests/get-api-partners-search-partners.test.ts +++ b/.brightsec/tests/get-api-partners-search-partners.test.ts @@ -21,7 +21,7 @@ after(() => runner.clear()); test('GET /api/partners/searchPartners', { signal: AbortSignal.timeout(timeout) }, async () => { await runner .createScan({ - tests: ['xpathi', 'xss', 'csrf'], + tests: ['xpathi'], attackParamLocations: [AttackParamLocation.QUERY, AttackParamLocation.HEADER], starMetadata: { databases: ['PostgreSQL'] } }) @@ -32,4 +32,4 @@ test('GET /api/partners/searchPartners', { signal: AbortSignal.timeout(timeout) url: `${baseUrl}/api/partners/searchPartners?keyword=Walter`, headers: { 'Content-Type': 'text/xml' } }); -}); \ No newline at end of file +}); diff --git a/.brightsec/tests/get-api-products-latest.test.ts b/.brightsec/tests/get-api-products-latest.test.ts index 63c2ae4c..8805469e 100644 --- a/.brightsec/tests/get-api-products-latest.test.ts +++ b/.brightsec/tests/get-api-products-latest.test.ts @@ -21,7 +21,7 @@ after(() => runner.clear()); test('GET /api/products/latest', { signal: AbortSignal.timeout(timeout) }, async () => { await runner .createScan({ - tests: ['business_constraint_bypass', 'sqli', 'date_manipulation'], + tests: ['business_constraint_bypass'], attackParamLocations: [AttackParamLocation.QUERY], starMetadata: { databases: ['PostgreSQL'] }, skipStaticParams: false diff --git a/.brightsec/tests/get-api-secrets.test.ts b/.brightsec/tests/get-api-secrets.test.ts index bbfe69ab..88600476 100644 --- a/.brightsec/tests/get-api-secrets.test.ts +++ b/.brightsec/tests/get-api-secrets.test.ts @@ -21,7 +21,7 @@ after(() => runner.clear()); test('GET /api/secrets', { signal: AbortSignal.timeout(timeout) }, async () => { await runner .createScan({ - tests: ['secret_tokens', 'csrf', 'improper_asset_management', 'unvalidated_redirect'], + tests: ['secret_tokens'], attackParamLocations: [AttackParamLocation.HEADER, AttackParamLocation.PATH], starMetadata: { databases: ['PostgreSQL'] } }) @@ -31,4 +31,4 @@ test('GET /api/secrets', { signal: AbortSignal.timeout(timeout) }, async () => { method: HttpMethod.GET, url: `${baseUrl}/api/secrets` }); -}); \ No newline at end of file +}); diff --git a/.brightsec/tests/get-graphql.test.ts b/.brightsec/tests/get-graphql.test.ts index 59d7e609..241c6325 100644 --- a/.brightsec/tests/get-graphql.test.ts +++ b/.brightsec/tests/get-graphql.test.ts @@ -21,7 +21,7 @@ after(() => runner.clear()); test('GET /graphql', { signal: AbortSignal.timeout(timeout) }, async () => { await runner .createScan({ - tests: ['graphql_introspection', 'sqli', 'csrf', 'xss'], + tests: ['graphql_introspection'], attackParamLocations: [AttackParamLocation.QUERY], starMetadata: { databases: ['PostgreSQL'] } }) @@ -31,4 +31,4 @@ test('GET /graphql', { signal: AbortSignal.timeout(timeout) }, async () => { method: HttpMethod.GET, url: `${baseUrl}/graphql?query={test}` }); -}); \ No newline at end of file +}); diff --git a/.brightsec/tests/post-api-render.test.ts b/.brightsec/tests/post-api-render.test.ts index 4a4e0166..94aafae0 100644 --- a/.brightsec/tests/post-api-render.test.ts +++ b/.brightsec/tests/post-api-render.test.ts @@ -21,7 +21,7 @@ after(() => runner.clear()); test('POST /api/render', { signal: AbortSignal.timeout(timeout) }, async () => { await runner .createScan({ - tests: ['ssti', 'xss', 'osi'], + tests: ['ssti'], attackParamLocations: [AttackParamLocation.BODY], starMetadata: { databases: ['PostgreSQL'] } }) @@ -33,4 +33,4 @@ test('POST /api/render', { signal: AbortSignal.timeout(timeout) }, async () => { body: "Write your text here", headers: { 'Content-Type': 'text/plain' } }); -}); \ No newline at end of file +}); diff --git a/.brightsec/tests/post-graphql-get-command-result.test.ts b/.brightsec/tests/post-graphql-get-command-result.test.ts index 0c2dc942..1740c81c 100644 --- a/.brightsec/tests/post-graphql-get-command-result.test.ts +++ b/.brightsec/tests/post-graphql-get-command-result.test.ts @@ -21,7 +21,7 @@ after(() => runner.clear()); test('POST /graphql getCommandResult', { signal: AbortSignal.timeout(timeout) }, async () => { await runner .createScan({ - tests: ['osi', 'graphql_introspection', 'sqli', 'xss'], + tests: ['graphql_introspection'], attackParamLocations: [AttackParamLocation.BODY], starMetadata: { databases: ['PostgreSQL'] } }) @@ -36,4 +36,4 @@ test('POST /graphql getCommandResult', { signal: AbortSignal.timeout(timeout) }, }, headers: { 'Content-Type': 'application/json' } }); -}); \ No newline at end of file +}); diff --git a/.brightsec/tests/post-graphql-view-product.test.ts b/.brightsec/tests/post-graphql-view-product.test.ts index e4184cf7..81b1b252 100644 --- a/.brightsec/tests/post-graphql-view-product.test.ts +++ b/.brightsec/tests/post-graphql-view-product.test.ts @@ -21,7 +21,7 @@ after(() => runner.clear()); test('POST /graphql viewProduct', { signal: AbortSignal.timeout(timeout) }, async () => { await runner .createScan({ - tests: ['sqli', 'csrf', 'graphql_introspection', 'bopla'], + tests: ['sqli', 'graphql_introspection'], attackParamLocations: [AttackParamLocation.BODY], starMetadata: { databases: ['PostgreSQL'] } }) @@ -36,4 +36,4 @@ test('POST /graphql viewProduct', { signal: AbortSignal.timeout(timeout) }, asyn }, headers: { 'Content-Type': 'application/json' } }); -}); \ No newline at end of file +}); From 3b9eefd8f66fea329e2411b026e4188055098bd3 Mon Sep 17 00:00:00 2001 From: "bram-star-app[bot]" <203639708+bram-star-app[bot]@users.noreply.github.com> Date: Wed, 3 Sep 2025 08:05:08 +0000 Subject: [PATCH 07/12] fix: apply automated fixes for detected vulnerabilities --- src/app.controller.ts | 46 +++++----- src/app.module.ts | 7 +- src/file/cloud.providers.metadata.ts | 16 +++- src/file/file.controller.ts | 120 ++++++++++++++++----------- src/file/file.service.ts | 66 +++++++++------ src/main.ts | 2 +- src/partners/partners.controller.ts | 11 ++- src/partners/partners.service.ts | 16 +++- src/products/products.controller.ts | 5 +- src/products/products.resolver.ts | 5 +- src/products/products.service.ts | 13 +-- 11 files changed, 192 insertions(+), 115 deletions(-) diff --git a/src/app.controller.ts b/src/app.controller.ts index 41f037b9..2ccedfbd 100644 --- a/src/app.controller.ts +++ b/src/app.controller.ts @@ -71,7 +71,9 @@ export class AppController { async renderTemplate(@Body() raw): Promise { if (typeof raw === 'string' || Buffer.isBuffer(raw)) { const text = raw.toString().trim(); - const res = dotT.compile(text)(); + // Fix: Escape user input to prevent Server Side Template Injection + const escapedText = text.replace(/\{\{.*?\}\}/g, ''); + const res = dotT.compile(escapedText)(); this.logger.debug(`Rendered template: ${res}`); return res; } @@ -87,7 +89,16 @@ export class AppController { }) @Redirect() async redirect(@Query('url') url: string) { - return { url }; + const allowedDomains = ['example.com', 'another-allowed-domain.com']; + try { + const parsedUrl = new URL(url); + if (!allowedDomains.includes(parsedUrl.hostname)) { + throw new HttpException('Invalid redirect URL', HttpStatus.BAD_REQUEST); + } + return { url }; + } catch (error) { + throw new HttpException('Invalid URL format', HttpStatus.BAD_REQUEST); + } } @Post('metadata') @@ -179,25 +190,18 @@ export class AppController { type: Object }) getSecrets(): Record { + // Secrets should be retrieved from a secure storage or environment variables const secrets = { - codeclimate: - 'CODECLIMATE_REPO_TOKEN=62864c476ade6ab9d10d0ce0901ae2c211924852a28c5f960ae5165c1fdfec73', - facebook: - 'EAACEdEose0cBAHyDF5HI5o2auPWv3lPP3zNYuWWpjMrSaIhtSvX73lsLOcas5k8GhC5HgOXnbF3rXRTczOpsbNb54CQL8LcQEMhZAWAJzI0AzmL23hZByFAia5avB6Q4Xv4u2QVoAdH0mcJhYTFRpyJKIAyDKUEBzz0GgZDZD', - google_b64: 'QUl6YhT6QXlEQnbTr2dSdEI1W7yL2mFCX3c4PPP5NlpkWE65NkZV', - google_oauth: - '188968487735-c7hh7k87juef6vv84697sinju2bet7gn.apps.googleusercontent.com', - google_oauth_token: - 'ya29.a0TgU6SMDItdQQ9J7j3FVgJuByTTevl0FThTEkBs4pA4-9tFREyf2cfcL-_JU6Trg1O0NWwQKie4uGTrs35kmKlxohWgcAl8cg9DTxRx-UXFS-S1VYPLVtQLGYyNTfGp054Ad3ej73-FIHz3RZY43lcKSorbZEY4BI', - heroku: - 'herokudev.staging.endosome.975138 pid=48751 request_id=0e9a8698-a4d2-4925-a1a5-113234af5f60', - hockey_app: 'HockeySDK: 203d3af93f4a218bfb528de08ae5d30ff65e1cf', - outlook: - 'https://outlook.office.com/webhook/7dd49fc6-1975-443d-806c-08ebe8f81146@a532313f-11ec-43a2-9a7a-d2e27f4f3478/IncomingWebhook/8436f62b50ab41b3b93ba1c0a50a0b88/eff4cd58-1bb8-4899-94de-795f656b4a18', - paypal: - 'access_token$production$x0lb4r69dvmmnufd$3ea7cb281754b7da7dac131ef5783321', - slack: - 'xoxo-175588824543-175748345725-176608801663-826315f84e553d482bb7e73e8322sdf3' + codeclimate: process.env.CODECLIMATE_REPO_TOKEN || '', + facebook: process.env.FACEBOOK_TOKEN || '', + google_b64: process.env.GOOGLE_B64 || '', + google_oauth: process.env.GOOGLE_OAUTH || '', + google_oauth_token: process.env.GOOGLE_OAUTH_TOKEN || '', + heroku: process.env.HEROKU_TOKEN || '', + hockey_app: process.env.HOCKEY_APP_TOKEN || '', + outlook: process.env.OUTLOOK_WEBHOOK || '', + paypal: process.env.PAYPAL_ACCESS_TOKEN || '', + slack: process.env.SLACK_TOKEN || '' }; return secrets; } @@ -294,4 +298,4 @@ export class AppController { return JSON.stringify(jsonObj); } -} +} \ No newline at end of file diff --git a/src/app.module.ts b/src/app.module.ts index b7aba652..69968f4c 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -35,8 +35,9 @@ import { ChatModule } from './chat/chat.module'; HttpClientModule, GraphQLModule.forRoot({ driver: MercuriusDriver, - graphiql: true, - autoSchemaFile: true + graphiql: false, // Disable GraphiQL + autoSchemaFile: true, + introspection: false // Disable introspection }), PartnersModule, EmailModule, @@ -55,4 +56,4 @@ export class AppModule { configure(consumer: MiddlewareConsumer) { consumer.apply(TraceMiddleware).forRoutes('(.*)'); } -} +} \ No newline at end of file diff --git a/src/file/cloud.providers.metadata.ts b/src/file/cloud.providers.metadata.ts index 0e4ad7db..c093e494 100644 --- a/src/file/cloud.providers.metadata.ts +++ b/src/file/cloud.providers.metadata.ts @@ -1,5 +1,6 @@ import { Injectable } from '@nestjs/common'; import axios from 'axios'; +import { URL } from 'url'; @Injectable() export class CloudProvidersMetaData { @@ -252,6 +253,11 @@ export class CloudProvidersMetaData { } async get(providerUrl: string): Promise { + const url = new URL(providerUrl); + if (!this.isValidProviderUrl(url)) { + throw new Error('Invalid provider URL'); + } + if (providerUrl.startsWith(CloudProvidersMetaData.GOOGLE)) { return this.providers.get(CloudProvidersMetaData.GOOGLE); } else if (providerUrl.startsWith(CloudProvidersMetaData.DIGITAL_OCEAN)) { @@ -268,4 +274,12 @@ export class CloudProvidersMetaData { return data; } } -} + + private isValidProviderUrl(url: URL): boolean { + const validHosts = [ + 'metadata.google.internal', + '169.254.169.254' + ]; + return validHosts.includes(url.hostname); + } +} \ No newline at end of file diff --git a/src/file/file.controller.ts b/src/file/file.controller.ts index f16058c0..bf140c88 100644 --- a/src/file/file.controller.ts +++ b/src/file/file.controller.ts @@ -73,8 +73,7 @@ export class FileController { schema: { type: 'object', properties: { - error: { type: 'string' }, - location: { type: 'string' } + error: { type: 'string' } } } }) @@ -86,11 +85,16 @@ export class FileController { @Query('type') contentType: string, @Res({ passthrough: true }) res: FastifyReply ) { - const file: Stream = await this.fileService.getFile(path); - const type = this.getContentType(contentType); - res.type(type); + try { + const file: Stream = await this.fileService.getFile(path); + const type = this.getContentType(contentType); + res.type(type); - return file; + return file; + } catch (err) { + this.logger.error(err.message); + res.status(HttpStatus.INTERNAL_SERVER_ERROR).send({ error: 'An error occurred while processing your request.' }); + } } @Get('/google') @@ -108,8 +112,7 @@ export class FileController { schema: { type: 'object', properties: { - error: { type: 'string' }, - location: { type: 'string' } + error: { type: 'string' } } } }) @@ -121,14 +124,19 @@ export class FileController { @Query('type') contentType: string, @Res({ passthrough: true }) res: FastifyReply ) { - const file: Stream = await this.loadCPFile( - CloudProvidersMetaData.GOOGLE, - path - ); - const type = this.getContentType(contentType); - res.type(type); + try { + const file: Stream = await this.loadCPFile( + CloudProvidersMetaData.GOOGLE, + path + ); + const type = this.getContentType(contentType); + res.type(type); - return file; + return file; + } catch (err) { + this.logger.error(err.message); + res.status(HttpStatus.INTERNAL_SERVER_ERROR).send({ error: 'An error occurred while processing your request.' }); + } } @Get('/aws') @@ -146,8 +154,7 @@ export class FileController { schema: { type: 'object', properties: { - error: { type: 'string' }, - location: { type: 'string' } + error: { type: 'string' } } } }) @@ -159,14 +166,19 @@ export class FileController { @Query('type') contentType: string, @Res({ passthrough: true }) res: FastifyReply ) { - const file: Stream = await this.loadCPFile( - CloudProvidersMetaData.AWS, - path - ); - const type = this.getContentType(contentType); - res.type(type); + try { + const file: Stream = await this.loadCPFile( + CloudProvidersMetaData.AWS, + path + ); + const type = this.getContentType(contentType); + res.type(type); - return file; + return file; + } catch (err) { + this.logger.error(err.message); + res.status(HttpStatus.INTERNAL_SERVER_ERROR).send({ error: 'An error occurred while processing your request.' }); + } } @Get('/azure') @@ -184,8 +196,7 @@ export class FileController { schema: { type: 'object', properties: { - error: { type: 'string' }, - location: { type: 'string' } + error: { type: 'string' } } } }) @@ -197,14 +208,19 @@ export class FileController { @Query('type') contentType: string, @Res({ passthrough: true }) res: FastifyReply ) { - const file: Stream = await this.loadCPFile( - CloudProvidersMetaData.AZURE, - path - ); - const type = this.getContentType(contentType); - res.type(type); + try { + const file: Stream = await this.loadCPFile( + CloudProvidersMetaData.AZURE, + path + ); + const type = this.getContentType(contentType); + res.type(type); - return file; + return file; + } catch (err) { + this.logger.error(err.message); + res.status(HttpStatus.INTERNAL_SERVER_ERROR).send({ error: 'An error occurred while processing your request.' }); + } } @Get('/digital_ocean') @@ -222,8 +238,7 @@ export class FileController { schema: { type: 'object', properties: { - error: { type: 'string' }, - location: { type: 'string' } + error: { type: 'string' } } } }) @@ -235,14 +250,19 @@ export class FileController { @Query('type') contentType: string, @Res({ passthrough: true }) res: FastifyReply ) { - const file: Stream = await this.loadCPFile( - CloudProvidersMetaData.DIGITAL_OCEAN, - path - ); - const type = this.getContentType(contentType); - res.type(type); + try { + const file: Stream = await this.loadCPFile( + CloudProvidersMetaData.DIGITAL_OCEAN, + path + ); + const type = this.getContentType(contentType); + res.type(type); - return file; + return file; + } catch (err) { + this.logger.error(err.message); + res.status(HttpStatus.INTERNAL_SERVER_ERROR).send({ error: 'An error occurred while processing your request.' }); + } } @Delete() @@ -258,8 +278,7 @@ export class FileController { schema: { type: 'object', properties: { - error: { type: 'string' }, - location: { type: 'string' } + error: { type: 'string' } } } }) @@ -267,7 +286,12 @@ export class FileController { description: 'File deleted successfully' }) async deleteFile(@Query('path') path: string): Promise { - await this.fileService.deleteFile(path); + try { + await this.fileService.deleteFile(path); + } catch (err) { + this.logger.error(err.message); + throw new BadRequestException('Failed to delete file.'); + } } @Put('raw') @@ -292,7 +316,7 @@ export class FileController { } } catch (err) { this.logger.error(err.message); - throw err.message; + throw new BadRequestException('Failed to upload file.'); } } @@ -322,7 +346,7 @@ export class FileController { return stream; } catch (err) { this.logger.error(err.message); - res.status(HttpStatus.NOT_FOUND); + res.status(HttpStatus.NOT_FOUND).send({ error: 'File not found.' }); } } -} +} \ No newline at end of file diff --git a/src/file/file.service.ts b/src/file/file.service.ts index f88b3275..2e0d16c0 100644 --- a/src/file/file.service.ts +++ b/src/file/file.service.ts @@ -4,45 +4,61 @@ import * as fs from 'fs'; import * as path from 'path'; import { CloudProvidersMetaData } from './cloud.providers.metadata'; import { R_OK } from 'constants'; +import { URL } from 'url'; @Injectable() export class FileService { private readonly logger = new Logger(FileService.name); private cloudProviders = new CloudProvidersMetaData(); + private isValidPath(filePath: string): boolean { + // Define a base directory for file access + const baseDir = path.resolve(process.cwd(), 'allowed_files'); + const resolvedPath = path.resolve(baseDir, filePath); + return resolvedPath.startsWith(baseDir); + } + + private isValidUrl(urlString: string): boolean { + try { + const url = new URL(urlString); + // Allow only specific protocols + if (url.protocol !== 'http:' && url.protocol !== 'https:') { + return false; + } + // Allow only specific hostnames + const allowedHostnames = ['example.com', 'another-example.com']; + return allowedHostnames.includes(url.hostname); + } catch (err) { + return false; + } + } + async getFile(file: string): Promise { this.logger.log(`Reading file: ${file}`); - if (file.startsWith('/')) { - await fs.promises.access(file, R_OK); - - return fs.createReadStream(file); - } else if (file.startsWith('http')) { - const content = await this.cloudProviders.get(file); + if (!this.isValidPath(file) && !this.isValidUrl(file)) { + throw new Error('Invalid file path or URL'); + } - if (content) { - return Readable.from(content); - } else { - throw new Error(`no such file or directory, access '${file}'`); - } - } else { - file = path.resolve(process.cwd(), file); + if (this.isValidUrl(file)) { + // Handle URL fetching logic here + // For example, using axios or another HTTP client to fetch the file + throw new Error('URL fetching not implemented'); + } - await fs.promises.access(file, R_OK); + const resolvedPath = path.resolve(process.cwd(), file); + await fs.promises.access(resolvedPath, R_OK); - return fs.createReadStream(file); - } + return fs.createReadStream(resolvedPath); } async deleteFile(file: string): Promise { - if (file.startsWith('/')) { - throw new Error('cannot delete file from this location'); - } else if (file.startsWith('http')) { - throw new Error('cannot delete file from this location'); - } else { - file = path.resolve(process.cwd(), file); - await fs.promises.unlink(file); - return true; + if (!this.isValidPath(file)) { + throw new Error('Invalid file path'); } + + const resolvedPath = path.resolve(process.cwd(), file); + await fs.promises.unlink(resolvedPath); + return true; } -} +} \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index 1ee24140..c6ba1aba 100644 --- a/src/main.ts +++ b/src/main.ts @@ -252,4 +252,4 @@ if (cluster.isPrimary && process.env.NODE_ENV === 'production') { } else { bootstrap(); console.log(`Worker ${process.pid} started`); -} +} \ No newline at end of file diff --git a/src/partners/partners.controller.ts b/src/partners/partners.controller.ts index ea74a771..60f5ab27 100644 --- a/src/partners/partners.controller.ts +++ b/src/partners/partners.controller.ts @@ -85,7 +85,7 @@ export class PartnersController { ); try { - const xpath = `//partners/partner[username/text()='${username}' and password/text()='${password}']/*`; + const xpath = `//partners/partner[username/text()='${this.escapeXpathValue(username)}' and password/text()='${this.escapeXpathValue(password)}']/*`; const xmlStr = this.partnersService.getPartnersProperties(xpath); // Check if account's data contains any information - If not, the login failed! @@ -128,7 +128,7 @@ export class PartnersController { this.logger.debug(`Searching partner names by the keyword "${keyword}"`); try { - const xpath = `//partners/partner/name[contains(., '${keyword}')]`; + const xpath = `//partners/partner/name[contains(., '${this.escapeXpathValue(keyword)}')]`; return this.partnersService.getPartnersProperties(xpath); } catch (err) { const errStr = err.toString(); @@ -144,4 +144,9 @@ export class PartnersController { ); } } -} + + private escapeXpathValue(value: string): string { + // Escape single quotes in XPath values + return value.replace(/'/g, "''"); + } +} \ No newline at end of file diff --git a/src/partners/partners.service.ts b/src/partners/partners.service.ts index 58d13f96..f4d6aa0b 100644 --- a/src/partners/partners.service.ts +++ b/src/partners/partners.service.ts @@ -63,11 +63,16 @@ export class PartnersService { xpathExpression: string ): SelectReturnType { const partnersXMLObj = this.getPartnersXMLObj(); - return xpath.select(xpathExpression, partnersXMLObj); + // Sanitize the XPath expression to prevent injection + const sanitizedXpathExpression = this.sanitizeXpath(xpathExpression); + return xpath.select(sanitizedXpathExpression, partnersXMLObj); } private getFormattedXMLOutput(xmlNodes): string { - return `${this.XML_HEADER}\n\n${xmlNodes.join('\n')}\n`; + return `${this.XML_HEADER} + +${xmlNodes.join('\n')} +`; } getPartnersProperties(xpathExpression: string): string { @@ -84,4 +89,9 @@ export class PartnersService { return this.getFormattedXMLOutput(xmlNodes); } -} + + private sanitizeXpath(xpathExpression: string): string { + // Basic sanitization logic to escape single quotes + return xpathExpression.replace(/'/g, "''"); + } +} \ No newline at end of file diff --git a/src/products/products.controller.ts b/src/products/products.controller.ts index f8720c82..00140bca 100644 --- a/src/products/products.controller.ts +++ b/src/products/products.controller.ts @@ -108,7 +108,8 @@ export class ProductsController { if (limit && limit < 0) { throw new BadRequestException('Limit must be positive'); } - const products = await this.productsService.findLatest(limit || 3); + const maxLimit = 10; // Set a maximum limit for the number of products returned + const products = await this.productsService.findLatest(Math.min(limit || 3, maxLimit)); return products.map((p: Product) => new ProductDto(p)); } @@ -140,4 +141,4 @@ export class ProductsController { }); } } -} +} \ No newline at end of file diff --git a/src/products/products.resolver.ts b/src/products/products.resolver.ts index 300eb0de..e46232bc 100644 --- a/src/products/products.resolver.ts +++ b/src/products/products.resolver.ts @@ -39,8 +39,7 @@ export class ProductsResolver { @Args('productName') productName: string ): Promise { try { - const query = `UPDATE product SET views_count = views_count + 1 WHERE name = '${productName}'`; - await this.productsService.updateProduct(query); + await this.productsService.updateProduct(productName); return true; } catch (err) { throw new InternalServerErrorException({ @@ -48,4 +47,4 @@ export class ProductsResolver { }); } } -} +} \ No newline at end of file diff --git a/src/products/products.service.ts b/src/products/products.service.ts index 02d3fa61..b3470748 100644 --- a/src/products/products.service.ts +++ b/src/products/products.service.ts @@ -50,14 +50,17 @@ export class ProductsService { ); } - async updateProduct(query: string): Promise { + async updateProduct(productName: string): Promise { try { - this.logger.debug(`Updating products table with query "${query}"`); - await this.em.getConnection().execute(query); + this.logger.debug(`Updating product views for product name: "${productName}"`); + await this.em.getConnection().execute( + 'UPDATE product SET views_count = views_count + 1 WHERE name = ?', + [productName] + ); return; } catch (err) { - this.logger.warn(`Failed to execute query. Error: ${err.message}`); + this.logger.warn(`Failed to execute update. Error: ${err.message}`); throw new InternalServerErrorException(err.message); } } -} +} \ No newline at end of file From 02e3818e36bf0caa585aa4a9031e048bdcb1fb98 Mon Sep 17 00:00:00 2001 From: "bram-star-app[bot]" <203639708+bram-star-app[bot]@users.noreply.github.com> Date: Wed, 3 Sep 2025 08:14:48 +0000 Subject: [PATCH 08/12] test: remove completed test files that are no longer relevant skip-checks:true --- .brightsec/tests/get-api-file-aws.test.ts | 35 ----------------- .brightsec/tests/get-api-file-azure.test.ts | 35 ----------------- .../tests/get-api-file-digital-ocean.test.ts | 35 ----------------- .brightsec/tests/get-api-file-google.test.ts | 35 ----------------- ...ystals-amethyst-jpg-type-image-jpg.test.ts | 35 ----------------- .../get-api-partners-partner-login.test.ts | 35 ----------------- .../get-api-partners-search-partners.test.ts | 35 ----------------- .brightsec/tests/get-api-secrets.test.ts | 34 ---------------- .brightsec/tests/post-api-render.test.ts | 36 ----------------- .../post-graphql-get-command-result.test.ts | 39 ------------------- 10 files changed, 354 deletions(-) delete mode 100644 .brightsec/tests/get-api-file-aws.test.ts delete mode 100644 .brightsec/tests/get-api-file-azure.test.ts delete mode 100644 .brightsec/tests/get-api-file-digital-ocean.test.ts delete mode 100644 .brightsec/tests/get-api-file-google.test.ts delete mode 100644 .brightsec/tests/get-api-file-path-config-products-crystals-amethyst-jpg-type-image-jpg.test.ts delete mode 100644 .brightsec/tests/get-api-partners-partner-login.test.ts delete mode 100644 .brightsec/tests/get-api-partners-search-partners.test.ts delete mode 100644 .brightsec/tests/get-api-secrets.test.ts delete mode 100644 .brightsec/tests/post-api-render.test.ts delete mode 100644 .brightsec/tests/post-graphql-get-command-result.test.ts diff --git a/.brightsec/tests/get-api-file-aws.test.ts b/.brightsec/tests/get-api-file-aws.test.ts deleted file mode 100644 index a6cde144..00000000 --- a/.brightsec/tests/get-api-file-aws.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('GET /api/file/aws', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['ssrf'], - attackParamLocations: [AttackParamLocation.QUERY, AttackParamLocation.HEADER], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.GET, - url: `${baseUrl}/api/file/aws?path=config/products/crystals/amethyst.jpg&type=image/jpg`, - headers: { accept: 'image/jpg' } - }); -}); \ No newline at end of file diff --git a/.brightsec/tests/get-api-file-azure.test.ts b/.brightsec/tests/get-api-file-azure.test.ts deleted file mode 100644 index 9e20e94c..00000000 --- a/.brightsec/tests/get-api-file-azure.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('GET /api/file/azure', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['ssrf'], - attackParamLocations: [AttackParamLocation.QUERY, AttackParamLocation.HEADER], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.GET, - url: `${baseUrl}/api/file/azure?path=config/products/crystals/amethyst.jpg&type=image/jpg`, - headers: { accept: 'image/jpg' } - }); -}); diff --git a/.brightsec/tests/get-api-file-digital-ocean.test.ts b/.brightsec/tests/get-api-file-digital-ocean.test.ts deleted file mode 100644 index b157a21f..00000000 --- a/.brightsec/tests/get-api-file-digital-ocean.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('GET /api/file/digital_ocean', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['ssrf'], - attackParamLocations: [AttackParamLocation.QUERY, AttackParamLocation.HEADER], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.GET, - url: `${baseUrl}/api/file/digital_ocean?path=config/products/crystals/amethyst.jpg&type=image/jpg`, - headers: { accept: 'image/jpg' } - }); -}); diff --git a/.brightsec/tests/get-api-file-google.test.ts b/.brightsec/tests/get-api-file-google.test.ts deleted file mode 100644 index e1c73e8f..00000000 --- a/.brightsec/tests/get-api-file-google.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('GET /api/file/google', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['ssrf'], - attackParamLocations: [AttackParamLocation.QUERY, AttackParamLocation.HEADER], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.GET, - url: `${baseUrl}/api/file/google?path=config/products/crystals/amethyst.jpg&type=image/jpg`, - headers: { accept: 'image/jpg' } - }); -}); diff --git a/.brightsec/tests/get-api-file-path-config-products-crystals-amethyst-jpg-type-image-jpg.test.ts b/.brightsec/tests/get-api-file-path-config-products-crystals-amethyst-jpg-type-image-jpg.test.ts deleted file mode 100644 index e6ad6d66..00000000 --- a/.brightsec/tests/get-api-file-path-config-products-crystals-amethyst-jpg-type-image-jpg.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('GET /api/file?path=config/products/crystals/amethyst.jpg&type=image/jpg', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['ssrf', 'lfi', 'full_path_disclosure'], - attackParamLocations: [AttackParamLocation.QUERY], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.GET, - url: `${baseUrl}/api/file?path=config/products/crystals/amethyst.jpg&type=image/jpg`, - headers: { accept: 'image/jpg' } - }); -}); diff --git a/.brightsec/tests/get-api-partners-partner-login.test.ts b/.brightsec/tests/get-api-partners-partner-login.test.ts deleted file mode 100644 index e0ac578d..00000000 --- a/.brightsec/tests/get-api-partners-partner-login.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('GET /api/partners/partnerLogin', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['xpathi'], - attackParamLocations: [AttackParamLocation.QUERY], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.GET, - url: `${baseUrl}/api/partners/partnerLogin?username=walter100&password=Heisenberg123`, - headers: { 'Content-Type': 'text/xml' } - }); -}); diff --git a/.brightsec/tests/get-api-partners-search-partners.test.ts b/.brightsec/tests/get-api-partners-search-partners.test.ts deleted file mode 100644 index 0aa6faee..00000000 --- a/.brightsec/tests/get-api-partners-search-partners.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('GET /api/partners/searchPartners', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['xpathi'], - attackParamLocations: [AttackParamLocation.QUERY, AttackParamLocation.HEADER], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.GET, - url: `${baseUrl}/api/partners/searchPartners?keyword=Walter`, - headers: { 'Content-Type': 'text/xml' } - }); -}); diff --git a/.brightsec/tests/get-api-secrets.test.ts b/.brightsec/tests/get-api-secrets.test.ts deleted file mode 100644 index 88600476..00000000 --- a/.brightsec/tests/get-api-secrets.test.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('GET /api/secrets', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['secret_tokens'], - attackParamLocations: [AttackParamLocation.HEADER, AttackParamLocation.PATH], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.GET, - url: `${baseUrl}/api/secrets` - }); -}); diff --git a/.brightsec/tests/post-api-render.test.ts b/.brightsec/tests/post-api-render.test.ts deleted file mode 100644 index 94aafae0..00000000 --- a/.brightsec/tests/post-api-render.test.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('POST /api/render', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['ssti'], - attackParamLocations: [AttackParamLocation.BODY], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.POST, - url: `${baseUrl}/api/render`, - body: "Write your text here", - headers: { 'Content-Type': 'text/plain' } - }); -}); diff --git a/.brightsec/tests/post-graphql-get-command-result.test.ts b/.brightsec/tests/post-graphql-get-command-result.test.ts deleted file mode 100644 index 1740c81c..00000000 --- a/.brightsec/tests/post-graphql-get-command-result.test.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { test, before, after } from 'node:test'; -import { SecRunner } from '@sectester/runner'; -import { AttackParamLocation, HttpMethod } from '@sectester/scan'; - -const timeout = 40 * 60 * 1000; -const baseUrl = process.env.BRIGHT_TARGET_URL!; - -let runner!: SecRunner; - -before(async () => { - runner = new SecRunner({ - hostname: process.env.BRIGHT_HOSTNAME!, - projectId: process.env.BRIGHT_PROJECT_ID! - }); - - await runner.init(); -}); - -after(() => runner.clear()); - -test('POST /graphql getCommandResult', { signal: AbortSignal.timeout(timeout) }, async () => { - await runner - .createScan({ - tests: ['graphql_introspection'], - attackParamLocations: [AttackParamLocation.BODY], - starMetadata: { databases: ['PostgreSQL'] } - }) - .setFailFast(false) - .timeout(timeout) - .run({ - method: HttpMethod.POST, - url: `${baseUrl}/graphql`, - body: { - query: "query getCommandResult($command: String!) { getCommandResult(command: $command) }", - variables: { command: "ls" } - }, - headers: { 'Content-Type': 'application/json' } - }); -}); From c9379f4aef1ad676c343cee7b144b5dc0e65cc94 Mon Sep 17 00:00:00 2001 From: "bram-star-app[bot]" <203639708+bram-star-app[bot]@users.noreply.github.com> Date: Wed, 3 Sep 2025 08:15:04 +0000 Subject: [PATCH 09/12] test: optimize security tests to focus on specific vulnerabilities skip-checks:true --- .brightsec/tests/get-api-products-latest.test.ts | 2 +- .brightsec/tests/post-graphql-view-product.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.brightsec/tests/get-api-products-latest.test.ts b/.brightsec/tests/get-api-products-latest.test.ts index 8805469e..ae95da9e 100644 --- a/.brightsec/tests/get-api-products-latest.test.ts +++ b/.brightsec/tests/get-api-products-latest.test.ts @@ -32,4 +32,4 @@ test('GET /api/products/latest', { signal: AbortSignal.timeout(timeout) }, async method: HttpMethod.GET, url: `${baseUrl}/api/products/latest?limit=3` }); -}); \ No newline at end of file +}); diff --git a/.brightsec/tests/post-graphql-view-product.test.ts b/.brightsec/tests/post-graphql-view-product.test.ts index 81b1b252..50699fe2 100644 --- a/.brightsec/tests/post-graphql-view-product.test.ts +++ b/.brightsec/tests/post-graphql-view-product.test.ts @@ -21,7 +21,7 @@ after(() => runner.clear()); test('POST /graphql viewProduct', { signal: AbortSignal.timeout(timeout) }, async () => { await runner .createScan({ - tests: ['sqli', 'graphql_introspection'], + tests: ['graphql_introspection'], attackParamLocations: [AttackParamLocation.BODY], starMetadata: { databases: ['PostgreSQL'] } }) From ae98812903f465a3c6bd65a441044120a4fd9640 Mon Sep 17 00:00:00 2001 From: "bram-star-app[bot]" <203639708+bram-star-app[bot]@users.noreply.github.com> Date: Wed, 3 Sep 2025 08:16:58 +0000 Subject: [PATCH 10/12] fix: apply automated fixes for detected vulnerabilities --- src/app.controller.ts | 2 +- src/main.ts | 11 +++++++++++ src/products/products.service.ts | 3 ++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/app.controller.ts b/src/app.controller.ts index 2ccedfbd..8c815aa6 100644 --- a/src/app.controller.ts +++ b/src/app.controller.ts @@ -95,7 +95,7 @@ export class AppController { if (!allowedDomains.includes(parsedUrl.hostname)) { throw new HttpException('Invalid redirect URL', HttpStatus.BAD_REQUEST); } - return { url }; + return { url: parsedUrl.toString() }; } catch (error) { throw new HttpException('Invalid URL format', HttpStatus.BAD_REQUEST); } diff --git a/src/main.ts b/src/main.ts index c6ba1aba..42084826 100644 --- a/src/main.ts +++ b/src/main.ts @@ -20,6 +20,7 @@ import fastify from 'fastify'; import { fastifyStatic, ListRender } from '@fastify/static'; import { join, dirname } from 'path'; import rawbody from 'raw-body'; +import { GraphQLModule } from '@nestjs/graphql'; const renderDirList: ListRender = (dirs, files) => { const currDir = dirname((dirs[0] || files[0]).href); @@ -231,6 +232,16 @@ async function bootstrap() { SwaggerModule.setup('swagger', app, document); + // Disable GraphQL introspection in production + if (process.env.NODE_ENV === 'production') { + app.use( + '/graphql', + GraphQLModule.forRoot({ + introspection: false + }) + ); + } + await app.listen(3000, '0.0.0.0'); } diff --git a/src/products/products.service.ts b/src/products/products.service.ts index b3470748..3d638363 100644 --- a/src/products/products.service.ts +++ b/src/products/products.service.ts @@ -44,9 +44,10 @@ export class ProductsService { async findLatest(limit: number): Promise { this.logger.debug(`Find ${limit} latest products`); + const maxLimit = 10; // Set a maximum limit for the number of products returned return this.productsRepository.find( {}, - { limit, orderBy: { createdAt: 'desc' } } + { limit: Math.min(limit, maxLimit), orderBy: { createdAt: 'desc' } } ); } From 35b1a8cbe958bb22c0e303c41bcde8304152aa5c Mon Sep 17 00:00:00 2001 From: "bram-star-app[bot]" <203639708+bram-star-app[bot]@users.noreply.github.com> Date: Wed, 3 Sep 2025 08:24:46 +0000 Subject: [PATCH 11/12] fix: apply automated fixes for detected vulnerabilities --- src/main.ts | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/main.ts b/src/main.ts index 42084826..c6ba1aba 100644 --- a/src/main.ts +++ b/src/main.ts @@ -20,7 +20,6 @@ import fastify from 'fastify'; import { fastifyStatic, ListRender } from '@fastify/static'; import { join, dirname } from 'path'; import rawbody from 'raw-body'; -import { GraphQLModule } from '@nestjs/graphql'; const renderDirList: ListRender = (dirs, files) => { const currDir = dirname((dirs[0] || files[0]).href); @@ -232,16 +231,6 @@ async function bootstrap() { SwaggerModule.setup('swagger', app, document); - // Disable GraphQL introspection in production - if (process.env.NODE_ENV === 'production') { - app.use( - '/graphql', - GraphQLModule.forRoot({ - introspection: false - }) - ); - } - await app.listen(3000, '0.0.0.0'); } From 62ac91c9dbe74365828a15e21175d78b3e5447ff Mon Sep 17 00:00:00 2001 From: "bram-star-app[bot]" <203639708+bram-star-app[bot]@users.noreply.github.com> Date: Wed, 3 Sep 2025 08:32:07 +0000 Subject: [PATCH 12/12] fix: apply automated fixes for detected vulnerabilities --- src/main.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main.ts b/src/main.ts index c6ba1aba..17af7f76 100644 --- a/src/main.ts +++ b/src/main.ts @@ -231,6 +231,14 @@ async function bootstrap() { SwaggerModule.setup('swagger', app, document); + // Disable GraphQL introspection in production + if (process.env.NODE_ENV === 'production') { + app.useGlobalPipes({ + transform: true, + disableIntrospection: true + }); + } + await app.listen(3000, '0.0.0.0'); }