Skip to content

Commit 192cf60

Browse files
authored
Merge pull request #1160 from serlo/staging
Deployment
2 parents a1bd278 + 18b0775 commit 192cf60

File tree

17 files changed

+2196
-1915
lines changed

17 files changed

+2196
-1915
lines changed

.github/dependabot.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ updates:
66
directory: '/'
77
schedule:
88
interval: 'weekly'
9+
groups:
10+
minor-and-patch:
11+
update-types:
12+
- 'patch'
13+
- 'minor'
914
ignore:
1015
# we want LTS version of node and not suggested current version
1116
- dependency-name: '@types/node'

.github/workflows/checks.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,34 @@ jobs:
1010
test:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v4
13+
- uses: actions/checkout@v5
1414
- uses: ./.github/actions/setup-node
1515
- run: yarn test
1616

1717
build:
1818
runs-on: ubuntu-latest
1919
steps:
20-
- uses: actions/checkout@v4
20+
- uses: actions/checkout@v5
2121
- uses: ./.github/actions/setup-node
2222
- run: yarn build --env production
2323

2424
eslint:
2525
runs-on: ubuntu-latest
2626
steps:
27-
- uses: actions/checkout@v4
27+
- uses: actions/checkout@v5
2828
- uses: ./.github/actions/setup-node
2929
- run: yarn lint:eslint
3030

3131
prettier:
3232
runs-on: ubuntu-latest
3333
steps:
34-
- uses: actions/checkout@v4
34+
- uses: actions/checkout@v5
3535
- uses: ./.github/actions/setup-node
3636
- run: yarn lint:prettier
3737

3838
tsc:
3939
runs-on: ubuntu-latest
4040
steps:
41-
- uses: actions/checkout@v4
41+
- uses: actions/checkout@v5
4242
- uses: ./.github/actions/setup-node
4343
- run: yarn lint:tsc

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
deploy:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v4
12+
- uses: actions/checkout@v5
1313
- uses: ./.github/actions/setup-node
1414
- run: yarn deploy --env ${GITHUB_REF_NAME}
1515
env:

.tool-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nodejs 20.12.1
1+
nodejs 24.9.0

__tests__/__utils__/services/database.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Instance } from '../../../src/utils'
22

33
declare global {
4-
// eslint-disable-next-line no-var
54
var uuids: Uuid[]
65
}
76

__tests__/__utils__/test-environment.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { CFEnvironment, CFVariables, isInstance } from '../../src/utils'
1212
const __dirname = path.dirname(fileURLToPath(import.meta.url))
1313

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

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import { givenUuid, currentTestEnvironment } from './__utils__'
2+
import { Instance } from '../src/utils'
3+
4+
describe('blocks common hacker paths', () => {
5+
const env = currentTestEnvironment()
6+
7+
beforeEach(() => {
8+
givenUuid({
9+
__typename: 'Article',
10+
alias: '/legitimate-path',
11+
content: 'legitimate content',
12+
instance: Instance.En,
13+
})
14+
})
15+
16+
test.each([
17+
'/.env',
18+
'/.git',
19+
'/.aws/config',
20+
'/.ssh/id_rsa',
21+
'/.docker/config',
22+
'/config.json',
23+
'/config.php',
24+
'/configuration.php',
25+
])('blocks file-based attack path: %s', async (path) => {
26+
const response = await env.fetch({ subdomain: 'en', pathname: path })
27+
expect(response.status).toBe(404)
28+
})
29+
30+
test.each([
31+
'/wp-admin',
32+
'/wp-login.php',
33+
'/wp-content/plugins',
34+
'/wp-includes/file.php',
35+
'/xmlrpc.php',
36+
'/wp-config.php',
37+
])('blocks WordPress-related path: %s', async (path) => {
38+
const response = await env.fetch({ subdomain: 'en', pathname: path })
39+
expect(response.status).toBe(404)
40+
})
41+
42+
test.each([
43+
'/phpmyadmin',
44+
'/pma',
45+
'/admin',
46+
'/administrator',
47+
'/cpanel',
48+
'/plesk',
49+
'/webmail',
50+
'/joomla/admin',
51+
'/drupal/admin',
52+
])('blocks CMS and admin panel path: %s', async (path) => {
53+
const response = await env.fetch({ subdomain: 'en', pathname: path })
54+
expect(response.status).toBe(404)
55+
})
56+
57+
test.each([
58+
'/test.php',
59+
'/index.asp',
60+
'/default.aspx',
61+
'/login.jsp',
62+
'/script.cgi',
63+
'/file.pl',
64+
])('blocks disallowed file extension: %s', async (path) => {
65+
const response = await env.fetch({ subdomain: 'en', pathname: path })
66+
expect(response.status).toBe(404)
67+
})
68+
69+
test('legitimate paths still work and redirect properly', async () => {
70+
const response = await env.fetch({
71+
subdomain: 'en',
72+
pathname: '/legitimate-path',
73+
})
74+
// This should not be blocked and should work as normal
75+
expect(response.status).not.toBe(404)
76+
})
77+
})

__tests__/redirects.ts

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,16 @@ test('de.serlo.org/datenschutz', async () => {
4545
expectToBeRedirectTo(response, target, 301)
4646
})
4747

48-
test('de.serlo.org/impressum', async () => {
49-
const response = await env.fetch({
50-
subdomain: 'de',
51-
pathname: '/impressum',
52-
})
53-
54-
const target = 'https://de.serlo.org/legal'
55-
expectToBeRedirectTo(response, target, 301)
56-
})
57-
58-
test('de.serlo.org/impressum', async () => {
59-
const response = await env.fetch({
60-
subdomain: 'de',
61-
pathname: '/imprint',
62-
})
63-
64-
const target = 'https://de.serlo.org/legal'
65-
expectToBeRedirectTo(response, target, 301)
48+
describe('Imprint', () => {
49+
test.each(['/impressum', '/imprint', '/legal'])(
50+
'de.serlo.org%s',
51+
async (pathname) => {
52+
const response = await env.fetch({ subdomain: 'de', pathname })
53+
54+
const target = 'https://chancenwerk.de/impressum/'
55+
expectToBeRedirectTo(response, target, 302)
56+
},
57+
)
6658
})
6759

6860
test('de.serlo.org/nutzungsbedingungen ', async () => {

jest.config.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
"^.+\\.tsx?$": [
44
"ts-jest",
55
{
6-
"useESM": true,
7-
"isolatedModules": true
6+
"useESM": true
87
}
98
]
109
},

jest.setup.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ function mockSentryServer() {
8282
export {}
8383

8484
declare global {
85-
// eslint-disable-next-line no-var
8685
var server: ReturnType<typeof import('msw/node').setupServer>
87-
// eslint-disable-next-line no-var
8886
var sentryEvents: SentryEvent[]
8987
}

0 commit comments

Comments
 (0)