Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .brightsec/tests/get-api-basketitems-1.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { test, before, after } from 'node:test';
import { SecRunner } from '@sectester/runner';
import { Severity, 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/basketitems/1', { signal: AbortSignal.timeout(timeout) }, async () => {
await runner
.createScan({
tests: ['jwt'],
attackParamLocations: [AttackParamLocation.PATH]
})
.threshold(Severity.CRITICAL)
.timeout(timeout)
.run({
method: HttpMethod.GET,
url: `${baseUrl}/api/BasketItems/1`,
auth: process.env.BRIGHT_AUTH_ID
});
});
34 changes: 34 additions & 0 deletions .brightsec/tests/get-api-basketitems.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { test, before, after } from 'node:test';
import { SecRunner } from '@sectester/runner';
import { Severity, 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/basketitems', { signal: AbortSignal.timeout(timeout) }, async () => {
await runner
.createScan({
tests: ['jwt'],
attackParamLocations: [AttackParamLocation.HEADER]
})
.threshold(Severity.CRITICAL)
.timeout(timeout)
.run({
method: HttpMethod.GET,
url: `${baseUrl}/api/BasketItems`,
auth: process.env.BRIGHT_AUTH_ID
});
});
35 changes: 35 additions & 0 deletions .brightsec/tests/get-api-users.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { test, before, after } from 'node:test';
import { SecRunner } from '@sectester/runner';
import { Severity, 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', { signal: AbortSignal.timeout(timeout) }, async () => {
await runner
.createScan({
tests: ['jwt'],
attackParamLocations: [AttackParamLocation.HEADER]
})
.threshold(Severity.CRITICAL)
.timeout(timeout)
.run({
method: HttpMethod.GET,
url: `${baseUrl}/api/Users`,
headers: { 'Authorization': 'Bearer <token>' },
auth: process.env.BRIGHT_AUTH_ID
});
});
35 changes: 35 additions & 0 deletions .brightsec/tests/get-rest-chatbot-status.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { test, before, after } from 'node:test';
import { SecRunner } from '@sectester/runner';
import { Severity, 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 /rest/chatbot/status', { signal: AbortSignal.timeout(timeout) }, async () => {
await runner
.createScan({
tests: ['jwt'],
attackParamLocations: [AttackParamLocation.HEADER]
})
.threshold(Severity.CRITICAL)
.timeout(timeout)
.run({
method: HttpMethod.GET,
url: `${baseUrl}/rest/chatbot/status`,
headers: { 'Content-Type': 'application/json' },
auth: process.env.BRIGHT_AUTH_ID
});
});
45 changes: 45 additions & 0 deletions .brightsec/tests/post-api-addresss.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { test, before, after } from 'node:test';
import { SecRunner } from '@sectester/runner';
import { Severity, 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/addresss', { signal: AbortSignal.timeout(timeout) }, async () => {
await runner
.createScan({
tests: ['id_enumeration'],
attackParamLocations: [AttackParamLocation.BODY]
})
.threshold(Severity.CRITICAL)
.timeout(timeout)
.run({
method: HttpMethod.POST,
url: `${baseUrl}/api/Addresss`,
body: {
UserId: 1,
fullName: 'John Doe',
mobileNum: 1234567890,
zipCode: '12345',
streetAddress: '123 Main St',
city: 'Metropolis',
state: 'NY',
country: 'USA'
},
headers: { 'Content-Type': 'application/json' },
auth: process.env.BRIGHT_AUTH_ID
});
});
54 changes: 54 additions & 0 deletions .github/workflows/bright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Bright

on:
pull_request:
branches: ['*']

permissions:
checks: write
contents: read

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: 22

- name: Install application dependencies
run: |
npm install --ignore-scripts
cd frontend
npm install --ignore-scripts --legacy-peer-deps

- name: Build and run application
run: |
docker build -t juice-shop .
docker run -d -p 3000:3000 juice-shop

- name: Wait for application to be ready
run: |
for i in {1..30}; do
nc -zv 127.0.0.1 3000 && echo "Application is ready" && exit 0
echo "Waiting for application..."
sleep 5
done
echo "Application did not start in time" && exit 1

- 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 }}
BRIGHT_TOKEN: ${{ secrets.BRIGHT_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_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
64 changes: 24 additions & 40 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
name: "CI/CD Pipeline"
on:
push:
branches-ignore:
- l10n_develop
- gh-pages
paths-ignore:
- '*.md'
- 'LICENSE'
- 'monitoring/grafana-dashboard.json'
- 'screenshots/**'
tags-ignore:
- '*'
pull_request:
paths-ignore:
- '*.md'
- 'LICENSE'
- 'data/static/i18n/*.json'
- 'frontend/src/assets/i18n/*.json'
workflow_dispatch:
# on:
# push:
# branches-ignore:
# - l10n_develop
# - gh-pages
# paths-ignore:
# - '*.md'
# - 'LICENSE'
# - 'monitoring/grafana-dashboard.json'
# - 'screenshots/**'
# tags-ignore:
# - '*'
# pull_request:
# paths-ignore:
# - '*.md'
# - 'LICENSE'
# - 'data/static/i18n/*.json'
# - 'frontend/src/assets/i18n/*.json'

env:
NODE_DEFAULT_VERSION: 22
NODE_OPTIONS: "--max_old_space_size=4096"
Expand All @@ -40,18 +43,8 @@ jobs:
run: npm run lint
- name: "Lint customization configs"
run: >
npm run lint:config -- -f ./config/7ms.yml &&
npm run lint:config -- -f ./config/addo.yml &&
npm run lint:config -- -f ./config/bodgeit.yml &&
npm run lint:config -- -f ./config/ctf.yml &&
npm run lint:config -- -f ./config/default.yml &&
npm run lint:config -- -f ./config/fbctf.yml &&
npm run lint:config -- -f ./config/juicebox.yml &&
npm run lint:config -- -f ./config/mozilla.yml &&
npm run lint:config -- -f ./config/oss.yml &&
npm run lint:config -- -f ./config/quiet.yml &&
npm run lint:config -- -f ./config/tutorial.yml &&
npm run lint:config -- -f ./config/unsafe.yml
npm run lint:config -- -f ./config/7ms.yml && npm run lint:config -- -f ./config/addo.yml && npm run lint:config -- -f ./config/bodgeit.yml && npm run lint:config -- -f ./config/ctf.yml && npm run lint:config -- -f ./config/default.yml && npm run lint:config -- -f ./config/fbctf.yml && npm run lint:config -- -f ./config/juicebox.yml && npm run lint:config -- -f ./config/mozilla.yml && npm run lint:config -- -f ./config/oss.yml && npm run lint:config -- -f ./config/quiet.yml && npm run lint:config -- -f ./config/tutorial.yml && npm run lint:config -- -f ./config/unsafe.yml

coding-challenge-rsn:
runs-on: windows-latest
steps:
Expand Down Expand Up @@ -184,17 +177,8 @@ jobs:
timeout_minutes: 30
max_attempts: 3
command: >
NODE_ENV=7ms npm run test:server &&
NODE_ENV=addo npm run test:server &&
NODE_ENV=bodgeit npm run test:server &&
NODE_ENV=ctf npm run test:server &&
NODE_ENV=fbctf npm run test:server &&
NODE_ENV=juicebox npm run test:server &&
NODE_ENV=mozilla npm run test:server &&
NODE_ENV=oss npm run test:server &&
NODE_ENV=quiet npm run test:server &&
NODE_ENV=tutorial npm run test:server &&
NODE_ENV=unsafe npm run test:server
NODE_ENV=7ms npm run test:server && NODE_ENV=addo npm run test:server && NODE_ENV=bodgeit npm run test:server && NODE_ENV=ctf npm run test:server && NODE_ENV=fbctf npm run test:server && NODE_ENV=juicebox npm run test:server && NODE_ENV=mozilla npm run test:server && NODE_ENV=oss npm run test:server && NODE_ENV=quiet npm run test:server && NODE_ENV=tutorial npm run test:server && NODE_ENV=unsafe npm run test:server

e2e:
runs-on: ${{ matrix.os }}
strategy:
Expand Down
37 changes: 19 additions & 18 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: "CodeQL Scan"

on:
push:
pull_request:
workflow_dispatch:
# on:
# push:
# pull_request:

jobs:
analyze:
Expand All @@ -15,19 +16,19 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'javascript-typescript' ]
language: ['javascript-typescript']
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
queries: security-extended
config: |
paths-ignore:
- 'data/static/codefixes'
- name: Autobuild
uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
queries: security-extended
config: |
paths-ignore:
- 'data/static/codefixes'
- name: Autobuild
uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
Loading
Loading