Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
138 commits
Select commit Hold shift + click to select a range
9480248
chore(deps-dev): bump msw from 2.7.3 to 2.7.5
dependabot[bot] Apr 28, 2025
b52b513
chore(deps-dev): bump @sentry/core from 9.10.1 to 9.14.0
dependabot[bot] Apr 28, 2025
00ca063
chore(deps-dev): bump @typescript-eslint/eslint-plugin
dependabot[bot] Apr 28, 2025
af4ed3d
chore(deps-dev): bump wrangler from 4.8.0 to 4.13.2
dependabot[bot] Apr 28, 2025
ee05e68
chore(deps-dev): bump @cloudflare/workers-types
dependabot[bot] Apr 28, 2025
1afde43
Merge pull request #1078 from serlo/dependabot/npm_and_yarn/cloudflar…
elbotho Apr 29, 2025
c81f7dc
Merge pull request #1077 from serlo/dependabot/npm_and_yarn/wrangler-…
elbotho Apr 29, 2025
e5506ac
Merge pull request #1076 from serlo/dependabot/npm_and_yarn/typescrip…
elbotho Apr 29, 2025
478dfc5
Merge pull request #1075 from serlo/dependabot/npm_and_yarn/sentry/co…
elbotho Apr 29, 2025
ba57d34
Merge pull request #1074 from serlo/dependabot/npm_and_yarn/msw-2.7.5
elbotho Apr 29, 2025
188f30c
chore(deps-dev): bump @eslint/js from 9.25.1 to 9.26.0
dependabot[bot] May 5, 2025
136cdd5
chore(deps-dev): bump wrangler from 4.13.2 to 4.14.1
dependabot[bot] May 5, 2025
7ab15aa
chore(deps-dev): bump @typescript-eslint/eslint-plugin
dependabot[bot] May 5, 2025
8ed298c
chore(deps-dev): bump msw from 2.7.5 to 2.7.6
dependabot[bot] May 5, 2025
c4af93d
chore(deps): bump fp-ts from 2.16.9 to 2.16.10
dependabot[bot] May 5, 2025
9dbae31
Merge pull request #1083 from serlo/dependabot/npm_and_yarn/fp-ts-2.1…
elbotho May 6, 2025
5300202
Merge pull request #1082 from serlo/dependabot/npm_and_yarn/msw-2.7.6
elbotho May 6, 2025
fc17407
Merge pull request #1081 from serlo/dependabot/npm_and_yarn/typescrip…
elbotho May 6, 2025
552d930
Merge pull request #1079 from serlo/dependabot/npm_and_yarn/eslint/js…
elbotho May 6, 2025
1fef315
Merge pull request #1080 from serlo/dependabot/npm_and_yarn/wrangler-…
elbotho May 6, 2025
5f727c7
chore(deps): bump jose from 6.0.10 to 6.0.11
dependabot[bot] May 12, 2025
6828dc2
chore(deps-dev): bump eslint from 9.25.1 to 9.26.0
dependabot[bot] May 12, 2025
1825ab4
chore(deps-dev): bump prettier-plugin-packagejson from 2.5.10 to 2.5.12
dependabot[bot] May 12, 2025
1b3700e
chore(deps-dev): bump @sentry/core from 9.14.0 to 9.17.0
dependabot[bot] May 12, 2025
3044164
Merge pull request #1088 from serlo/dependabot/npm_and_yarn/sentry/co…
elbotho May 12, 2025
0882582
Merge pull request #1087 from serlo/dependabot/npm_and_yarn/prettier-…
elbotho May 12, 2025
fec4274
Merge pull request #1086 from serlo/dependabot/npm_and_yarn/eslint-9.…
elbotho May 12, 2025
4f47dc3
Merge pull request #1085 from serlo/dependabot/npm_and_yarn/jose-6.0.11
elbotho May 12, 2025
a1185df
chore(deps-dev): bump @typescript-eslint/parser from 8.31.0 to 8.32.1
dependabot[bot] May 12, 2025
092e349
Merge pull request #1084 from serlo/dependabot/npm_and_yarn/typescrip…
elbotho May 13, 2025
f599492
chore(deps): bump undici from 5.28.5 to 5.29.0
dependabot[bot] May 15, 2025
88293d8
Merge pull request #1089 from serlo/dependabot/npm_and_yarn/undici-5.…
elbotho May 15, 2025
058fefb
chore(deps-dev): bump wrangler from 4.14.1 to 4.15.2
dependabot[bot] May 19, 2025
a1984fe
chore(deps-dev): bump globals from 16.0.0 to 16.1.0
dependabot[bot] May 19, 2025
ecc2b00
chore(deps-dev): bump @eslint/js from 9.26.0 to 9.27.0
dependabot[bot] May 19, 2025
2f49dbb
Merge pull request #1094 from serlo/dependabot/npm_and_yarn/eslint/js…
elbotho May 20, 2025
f978076
Merge pull request #1093 from serlo/dependabot/npm_and_yarn/globals-1…
elbotho May 20, 2025
1fd6117
Merge pull request #1091 from serlo/dependabot/npm_and_yarn/wrangler-…
elbotho May 20, 2025
24f47a3
chore(deps-dev): bump @sentry/core from 9.17.0 to 9.20.0
dependabot[bot] May 20, 2025
0fc9cd6
Merge pull request #1090 from serlo/dependabot/npm_and_yarn/sentry/co…
elbotho May 20, 2025
048092d
chore(deps-dev): bump eslint from 9.26.0 to 9.27.0
dependabot[bot] May 20, 2025
cd2077d
Merge pull request #1092 from serlo/dependabot/npm_and_yarn/eslint-9.…
elbotho May 20, 2025
b8ebfa5
chore(deps-dev): bump globals from 16.1.0 to 16.2.0
dependabot[bot] May 26, 2025
40d16ea
chore(deps-dev): bump wrangler from 4.15.2 to 4.16.1
dependabot[bot] May 26, 2025
652eac6
chore(deps-dev): bump @eslint/compat from 1.2.8 to 1.2.9
dependabot[bot] May 26, 2025
e6804df
chore(deps-dev): bump eslint-config-prettier from 10.1.2 to 10.1.5
dependabot[bot] May 26, 2025
e8c209f
Merge pull request #1099 from serlo/dependabot/npm_and_yarn/eslint-co…
elbotho May 27, 2025
6a0bdf3
Merge pull request #1098 from serlo/dependabot/npm_and_yarn/eslint/co…
elbotho May 27, 2025
f29b756
Merge pull request #1097 from serlo/dependabot/npm_and_yarn/wrangler-…
elbotho May 27, 2025
ae89294
Merge pull request #1096 from serlo/dependabot/npm_and_yarn/globals-1…
elbotho May 27, 2025
64fbb6d
chore(deps-dev): bump ts-jest from 29.3.2 to 29.3.4
dependabot[bot] May 27, 2025
fc6f896
Merge pull request #1095 from serlo/dependabot/npm_and_yarn/ts-jest-2…
elbotho May 27, 2025
ecf4e8d
chore(deps-dev): bump prettier-plugin-sh from 0.17.2 to 0.17.4
dependabot[bot] Jun 2, 2025
09a6b18
chore(deps-dev): bump msw from 2.7.6 to 2.10.2
dependabot[bot] Jun 9, 2025
5c773a0
chore(deps-dev): bump @eslint/js from 9.27.0 to 9.29.0
dependabot[bot] Jun 17, 2025
6f66e19
chore(deps-dev): bump wrangler from 4.16.1 to 4.20.0
dependabot[bot] Jun 17, 2025
5bbf61d
chore(deps-dev): bump @typescript-eslint/parser from 8.32.1 to 8.34.1
dependabot[bot] Jun 17, 2025
416a201
Merge pull request #1101 from serlo/dependabot/npm_and_yarn/prettier-…
elbotho Jun 17, 2025
876e9f4
Merge pull request #1107 from serlo/dependabot/npm_and_yarn/msw-2.10.2
elbotho Jun 17, 2025
1c441a2
Merge pull request #1108 from serlo/dependabot/npm_and_yarn/eslint/js…
elbotho Jun 17, 2025
65f2003
Merge pull request #1109 from serlo/dependabot/npm_and_yarn/wrangler-…
elbotho Jun 17, 2025
276aeb0
Merge pull request #1110 from serlo/dependabot/npm_and_yarn/typescrip…
elbotho Jun 17, 2025
1dd1c70
chore(deps-dev): bump wrangler from 4.20.0 to 4.22.0
dependabot[bot] Jul 1, 2025
1159cd3
chore(deps-dev): bump @sentry/core from 9.20.0 to 9.33.0
dependabot[bot] Jul 1, 2025
97d023d
chore(deps-dev): bump @eslint/compat from 1.2.9 to 1.3.1
dependabot[bot] Jul 1, 2025
52aca44
Merge pull request #1116 from serlo/dependabot/npm_and_yarn/wrangler-…
elbotho Jul 2, 2025
bbd0624
Merge pull request #1117 from serlo/dependabot/npm_and_yarn/sentry/co…
elbotho Jul 2, 2025
780a29f
Merge pull request #1120 from serlo/dependabot/npm_and_yarn/eslint/co…
elbotho Jul 2, 2025
e2a6523
chore(deps-dev): bump @cloudflare/workers-types
dependabot[bot] Jul 2, 2025
0f3c6d7
Merge pull request #1119 from serlo/dependabot/npm_and_yarn/cloudflar…
elbotho Jul 2, 2025
0e42584
chore: Update dependencies
kulla Jul 16, 2025
7e5e2dc
chore: Run "yarn dedupe"
kulla Jul 16, 2025
e4d11a2
Merge pull request #1128 from serlo/rh2r6-kulla-2025-07-16-09-22
kulla Jul 16, 2025
c78f24c
chore(deps-dev): bump @cloudflare/workers-types
dependabot[bot] Jul 22, 2025
58f7d6c
chore(deps-dev): bump wrangler from 4.24.3 to 4.25.0
dependabot[bot] Jul 22, 2025
6f9f25a
chore(deps-dev): bump @typescript-eslint/eslint-plugin
dependabot[bot] Jul 22, 2025
8bdb458
Merge pull request #1132 from serlo/dependabot/npm_and_yarn/typescrip…
kulla Aug 4, 2025
8d78ec5
Merge pull request #1130 from serlo/dependabot/npm_and_yarn/cloudflar…
kulla Aug 4, 2025
7df9686
Merge pull request #1131 from serlo/dependabot/npm_and_yarn/wrangler-…
kulla Aug 4, 2025
8e6c01c
chore(deps-dev): bump @typescript-eslint/parser from 8.37.0 to 8.38.0
dependabot[bot] Aug 4, 2025
84bc449
Merge pull request #1129 from serlo/dependabot/npm_and_yarn/typescrip…
kulla Aug 4, 2025
e5909e8
chore(deps-dev): bump eslint-config-prettier from 10.1.5 to 10.1.8
dependabot[bot] Aug 5, 2025
c8d9942
chore(deps-dev): bump jest and @types/jest
dependabot[bot] Aug 5, 2025
a35f23a
chore(deps): bump actions/checkout from 4 to 5
dependabot[bot] Aug 12, 2025
9fc3595
chore(deps-dev): bump wrangler from 4.25.0 to 4.32.0
dependabot[bot] Aug 26, 2025
6ebf2c7
chore(deps-dev): bump @eslint/js from 9.31.0 to 9.34.0
dependabot[bot] Aug 26, 2025
5911646
Merge pull request #1143 from serlo/dependabot/npm_and_yarn/eslint/js…
kulla Aug 28, 2025
e32c70d
Merge pull request #1142 from serlo/dependabot/npm_and_yarn/wrangler-…
kulla Aug 28, 2025
082e9b1
Merge pull request #1133 from serlo/dependabot/npm_and_yarn/eslint-co…
kulla Aug 28, 2025
23fa874
Merge pull request #1134 from serlo/dependabot/npm_and_yarn/multi-5ae…
kulla Aug 28, 2025
cf4ad3a
Merge pull request #1139 from serlo/dependabot/github_actions/actions…
kulla Aug 28, 2025
bd87ed8
chore(deps-dev): bump @jest/globals from 29.7.0 to 30.0.5
dependabot[bot] Aug 28, 2025
dde0bb9
chore(tsconfig): Set lib=es2023
kulla Aug 28, 2025
9a9623c
chore: Add dev dependency "@types/node"
kulla Aug 28, 2025
af721b5
Merge pull request #1137 from serlo/dependabot/npm_and_yarn/jest/glob…
kulla Aug 28, 2025
60efd13
chore: Run "yarn dedupe"
kulla Aug 28, 2025
351f179
test: Remove unecessary eslint ignore comments
kulla Aug 28, 2025
58880eb
chore: Set env in "yarn build" to avoid warning
kulla Aug 28, 2025
019a679
chore(tsconfig): Specify "isolatedModules"
kulla Aug 28, 2025
2b05d57
fix: Add --env in "yarn build"
kulla Aug 28, 2025
bcf83d7
Merge pull request #1144 from serlo/m7Ew3-kulla-2025-08-28-14-31
kulla Aug 28, 2025
48d0c14
chore: Update dependencies
kulla Aug 28, 2025
89360d0
Merge pull request #1145 from serlo/SbBlj-kulla-2025-08-28-14-44
kulla Aug 28, 2025
e8d0667
chore(dependabot): Group minor and patch updates
kulla Aug 28, 2025
7e53c7a
Merge pull request #1146 from serlo/f5Ilu-kulla-2025-08-28-14-53
kulla Aug 28, 2025
2866862
chore(deps-dev): bump @sentry/core from 9.46.0 to 10.7.0
dependabot[bot] Aug 28, 2025
4949955
Merge pull request #1147 from serlo/dependabot/npm_and_yarn/sentry/co…
kulla Aug 28, 2025
2059443
chore(deps-dev): bump the minor-and-patch group with 5 updates
dependabot[bot] Sep 2, 2025
247ef7c
Merge pull request #1148 from serlo/dependabot/npm_and_yarn/minor-and…
kulla Sep 2, 2025
0268bfd
chore(deps-dev): bump the minor-and-patch group with 9 updates
dependabot[bot] Sep 8, 2025
de08211
Merge pull request #1149 from serlo/dependabot/npm_and_yarn/minor-and…
kulla Sep 9, 2025
8415ab0
chore(deps-dev): bump the minor-and-patch group with 9 updates
dependabot[bot] Sep 15, 2025
5cf637e
Merge pull request #1150 from serlo/dependabot/npm_and_yarn/minor-and…
kulla Sep 16, 2025
4c59276
chore(deps-dev): bump the minor-and-patch group with 11 updates
dependabot[bot] Sep 22, 2025
334ef8b
Merge pull request #1151 from serlo/dependabot/npm_and_yarn/minor-and…
kulla Sep 23, 2025
a7c30f4
chore(deps-dev): bump the minor-and-patch group with 9 updates
dependabot[bot] Sep 29, 2025
e8f2c3c
Merge pull request #1152 from serlo/dependabot/npm_and_yarn/minor-and…
kulla Sep 30, 2025
98f90c9
chore: Run "yarn dedupe"
kulla Sep 30, 2025
8e69d27
Merge pull request #1153 from serlo/CfXLP-kulla-2025-09-30-12-23
kulla Sep 30, 2025
12f35fa
Initial plan
Copilot Sep 30, 2025
44b3803
Update Node.js version to v24.9.0
Copilot Sep 30, 2025
fe38651
chore: Run "yarn dedupe"
kulla Sep 30, 2025
470e7aa
chore: Update cloudflare worker types
kulla Sep 30, 2025
2a5c92c
Merge pull request #1154 from serlo/copilot/fix-2c5acc5b-8413-4faf-bd…
kulla Sep 30, 2025
37de784
Initial plan
Copilot Sep 30, 2025
ab3e97e
Block common hacker paths from reaching the database
Copilot Sep 30, 2025
5b80761
Return 404 response for common hacker paths
Copilot Sep 30, 2025
70a1a9d
refactor: Add new file src/block-common-hacker-paths.ts
kulla Sep 30, 2025
83c0072
Merge pull request #1155 from serlo/copilot/fix-776008d8-73f6-4320-af…
kulla Sep 30, 2025
057730c
chore(deps-dev): bump the minor-and-patch group with 10 updates
dependabot[bot] Oct 6, 2025
15de924
Merge pull request #1156 from serlo/dependabot/npm_and_yarn/minor-and…
kulla Oct 8, 2025
1ed9f5e
chore(deps-dev): bump the minor-and-patch group with 8 updates
dependabot[bot] Oct 13, 2025
2e283f2
Merge pull request #1157 from serlo/dependabot/npm_and_yarn/minor-and…
kulla Oct 20, 2025
92c0223
chore: Run "yarn dedupe"
kulla Oct 20, 2025
24903f2
Merge pull request #1158 from serlo/57g0a-kulla-2025-10-20-10-41
kulla Oct 20, 2025
9242b01
feat: Add redirect for "/legal"
kulla Oct 20, 2025
eaaca7f
test: Fix tests for imprint redirects
kulla Oct 20, 2025
18b0775
Merge pull request #1159 from serlo/EnGfL-kulla-2025-10-20-20-03
kulla Oct 20, 2025
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
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ updates:
directory: '/'
schedule:
interval: 'weekly'
groups:
minor-and-patch:
update-types:
- 'patch'
- 'minor'
ignore:
# we want LTS version of node and not suggested current version
- dependency-name: '@types/node'
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,34 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- uses: ./.github/actions/setup-node
- run: yarn test

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- uses: ./.github/actions/setup-node
- run: yarn build --env production

eslint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- uses: ./.github/actions/setup-node
- run: yarn lint:eslint

prettier:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- uses: ./.github/actions/setup-node
- run: yarn lint:prettier

tsc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- uses: ./.github/actions/setup-node
- run: yarn lint:tsc
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- uses: ./.github/actions/setup-node
- run: yarn deploy --env ${GITHUB_REF_NAME}
env:
Expand Down
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nodejs 20.12.1
nodejs 24.9.0
1 change: 0 additions & 1 deletion __tests__/__utils__/services/database.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Instance } from '../../../src/utils'

declare global {
// eslint-disable-next-line no-var
var uuids: Uuid[]
}

Expand Down
1 change: 0 additions & 1 deletion __tests__/__utils__/test-environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { CFEnvironment, CFVariables, isInstance } from '../../src/utils'
const __dirname = path.dirname(fileURLToPath(import.meta.url))

declare global {
// eslint-disable-next-line no-var
var server: ReturnType<typeof import('msw/node').setupServer>
}

Expand Down
77 changes: 77 additions & 0 deletions __tests__/block-common-hacker-paths.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { givenUuid, currentTestEnvironment } from './__utils__'
import { Instance } from '../src/utils'

describe('blocks common hacker paths', () => {
const env = currentTestEnvironment()

beforeEach(() => {
givenUuid({
__typename: 'Article',
alias: '/legitimate-path',
content: 'legitimate content',
instance: Instance.En,
})
})

test.each([
'/.env',
'/.git',
'/.aws/config',
'/.ssh/id_rsa',
'/.docker/config',
'/config.json',
'/config.php',
'/configuration.php',
])('blocks file-based attack path: %s', async (path) => {
const response = await env.fetch({ subdomain: 'en', pathname: path })
expect(response.status).toBe(404)
})

test.each([
'/wp-admin',
'/wp-login.php',
'/wp-content/plugins',
'/wp-includes/file.php',
'/xmlrpc.php',
'/wp-config.php',
])('blocks WordPress-related path: %s', async (path) => {
const response = await env.fetch({ subdomain: 'en', pathname: path })
expect(response.status).toBe(404)
})

test.each([
'/phpmyadmin',
'/pma',
'/admin',
'/administrator',
'/cpanel',
'/plesk',
'/webmail',
'/joomla/admin',
'/drupal/admin',
])('blocks CMS and admin panel path: %s', async (path) => {
const response = await env.fetch({ subdomain: 'en', pathname: path })
expect(response.status).toBe(404)
})

test.each([
'/test.php',
'/index.asp',
'/default.aspx',
'/login.jsp',
'/script.cgi',
'/file.pl',
])('blocks disallowed file extension: %s', async (path) => {
const response = await env.fetch({ subdomain: 'en', pathname: path })
expect(response.status).toBe(404)
})

test('legitimate paths still work and redirect properly', async () => {
const response = await env.fetch({
subdomain: 'en',
pathname: '/legitimate-path',
})
// This should not be blocked and should work as normal
expect(response.status).not.toBe(404)
})
})
28 changes: 10 additions & 18 deletions __tests__/redirects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,16 @@ test('de.serlo.org/datenschutz', async () => {
expectToBeRedirectTo(response, target, 301)
})

test('de.serlo.org/impressum', async () => {
const response = await env.fetch({
subdomain: 'de',
pathname: '/impressum',
})

const target = 'https://de.serlo.org/legal'
expectToBeRedirectTo(response, target, 301)
})

test('de.serlo.org/impressum', async () => {
const response = await env.fetch({
subdomain: 'de',
pathname: '/imprint',
})

const target = 'https://de.serlo.org/legal'
expectToBeRedirectTo(response, target, 301)
describe('Imprint', () => {
test.each(['/impressum', '/imprint', '/legal'])(
'de.serlo.org%s',
async (pathname) => {
const response = await env.fetch({ subdomain: 'de', pathname })

const target = 'https://chancenwerk.de/impressum/'
expectToBeRedirectTo(response, target, 302)
},
)
})

test('de.serlo.org/nutzungsbedingungen ', async () => {
Expand Down
3 changes: 1 addition & 2 deletions jest.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"^.+\\.tsx?$": [
"ts-jest",
{
"useESM": true,
"isolatedModules": true
"useESM": true
}
]
},
Expand Down
2 changes: 0 additions & 2 deletions jest.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ function mockSentryServer() {
export {}

declare global {
// eslint-disable-next-line no-var
var server: ReturnType<typeof import('msw/node').setupServer>
// eslint-disable-next-line no-var
var sentryEvents: SentryEvent[]
}
51 changes: 26 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,45 +30,46 @@
"test:staging": "cross-env TEST_ENVIRONMENT=staging yarn test --runInBand"
},
"dependencies": {
"fp-ts": "^2.16.9",
"fp-ts": "^2.16.11",
"io-ts": "^2.2.22",
"jose": "^6.0.10",
"jose": "^6.1.0",
"toucan-js": "^4.1.1"
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20250421.0",
"@eslint/compat": "^1.2.8",
"@cloudflare/workers-types": "^4.20251011.0",
"@eslint/compat": "^1.4.0",
"@eslint/eslintrc": "^3.3.1",
"@eslint/js": "^9.25.1",
"@eslint/js": "^9.37.0",
"@iarna/toml": "^2.2.5",
"@jest/globals": "^29.7.0",
"@sentry/core": "^9.10.1",
"@testing-library/jest-dom": "^6.6.3",
"@jest/globals": "^30.2.0",
"@sentry/core": "^10.19.0",
"@testing-library/jest-dom": "^6.9.1",
"@types/iarna__toml": "^2.0.5",
"@types/jest": "^29.5.14",
"@typescript-eslint/eslint-plugin": "^8.31.0",
"@typescript-eslint/parser": "^8.31.0",
"cross-env": "^7.0.3",
"@types/jest": "^30.0.0",
"@types/node": "24.7.2",
"@typescript-eslint/eslint-plugin": "^8.46.1",
"@typescript-eslint/parser": "^8.46.1",
"cross-env": "^10.1.0",
"depcheck": "^1.4.7",
"eslint": "^9.25.1",
"eslint-config-prettier": "^10.1.2",
"eslint": "^9.37.0",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-deprecation": "^3.0.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-react": "^7.37.5",
"globals": "^16.0.0",
"jest": "^29.7.0",
"msw": "^2.7.3",
"globals": "^16.4.0",
"jest": "^30.2.0",
"msw": "^2.11.5",
"npm-run-all": "^4.1.5",
"prettier": "^3.5.3",
"prettier-plugin-packagejson": "^2.5.10",
"prettier-plugin-sh": "^0.17.2",
"ts-jest": "^29.3.2",
"prettier": "^3.6.2",
"prettier-plugin-packagejson": "^2.5.19",
"prettier-plugin-sh": "^0.18.0",
"ts-jest": "^29.4.5",
"ts-unused-exports": "^11.0.1",
"typescript": "^5.8.3",
"wrangler": "^4.8.0"
"typescript": "^5.9.3",
"wrangler": "^4.42.2"
},
"packageManager": "yarn@3.6.0",
"engines": {
"node": "^20.0.0"
"node": "^24.0.0"
}
}
2 changes: 1 addition & 1 deletion scripts/run_all_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function main() {
yarn test

print_header "Run build"
yarn build
yarn build --env staging
}

function test_no_uncommitted_changes_when_pushing() {
Expand Down
73 changes: 73 additions & 0 deletions src/block-common-hacker-paths.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { Url, isInstance } from './utils'

export function blockCommonHackerPaths(request: Request) {
const url = Url.fromRequest(request)

if (isInstance(url.subdomain)) {
// Block common hacker paths with 404 response
if (isCommonHackerPath(url.pathname)) {
return new Response('Not Found', { status: 404 })
}
}

return null
}

function isCommonHackerPath(path: string): boolean {
const lowerPath = path.toLowerCase()

// Common file-based attacks
if (
lowerPath.startsWith('/.env') ||
lowerPath.startsWith('/.git') ||
lowerPath.startsWith('/.aws') ||
lowerPath.startsWith('/.ssh') ||
lowerPath.startsWith('/.docker') ||
lowerPath === '/config.json' ||
lowerPath === '/config.php' ||
lowerPath === '/configuration.php'
) {
return true
}

// WordPress-related paths
if (
lowerPath.startsWith('/wp-admin') ||
lowerPath.startsWith('/wp-login') ||
lowerPath.startsWith('/wp-content') ||
lowerPath.startsWith('/wp-includes') ||
lowerPath === '/xmlrpc.php' ||
lowerPath === '/wp-config.php'
) {
return true
}

// Other CMS and admin panels
if (
lowerPath.startsWith('/phpmyadmin') ||
lowerPath.startsWith('/pma') ||
lowerPath.startsWith('/admin') ||
lowerPath.startsWith('/administrator') ||
lowerPath.startsWith('/cpanel') ||
lowerPath.startsWith('/plesk') ||
lowerPath.startsWith('/webmail') ||
lowerPath.startsWith('/joomla') ||
lowerPath.startsWith('/drupal')
) {
return true
}

// Common file extensions that Serlo doesn't use
if (
lowerPath.endsWith('.php') ||
lowerPath.endsWith('.asp') ||
lowerPath.endsWith('.aspx') ||
lowerPath.endsWith('.jsp') ||
lowerPath.endsWith('.cgi') ||
lowerPath.endsWith('.pl')
) {
return true
}

return false
}
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { api } from './api'
import { assetProxy } from './asset-proxy'
import { semanticFileNames } from './assets'
import { auth } from './auth'
import { blockCommonHackerPaths } from './block-common-hacker-paths'
import { cloudflareWorkerDev } from './cloudflare-worker-dev'
import { redirectToCurrentAlias } from './current-alias-redirects'
import { embed } from './embed'
Expand Down Expand Up @@ -30,6 +31,7 @@ export default {
(await quickbarProxy(request, sentryFactory)) ||
(await pdfProxy(request, sentryFactory)) ||
robotsTxt(request, env) ||
blockCommonHackerPaths(request) ||
(await frontendSpecialPaths(request, sentryFactory, env)) ||
sentryHelloWorld(request, sentryFactory) ||
redirects(request, env) ||
Expand Down
3 changes: 2 additions & 1 deletion src/redirects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export function redirects(request: Request, env: CFEnvironment) {
return Response.redirect('https://de.serlo.org/privacy', 301)
case '/impressum':
case '/imprint':
return Response.redirect('https://de.serlo.org/legal', 301)
case '/legal':
return Response.redirect('https://chancenwerk.de/impressum/', 302)
case '/nutzungsbedingungen':
case '/21654':
case '/21654/nutzungsbedingungen-und-urheberrecht':
Expand Down
Loading