create-astram-app 0.14.2 → 0.14.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/template/frontend/package.json +1 -1
- package/template/frontend/src/pages/Login.jsx +5 -2
- package/template/frontend/src/shell/notificationsView.js +37 -4
- package/template/frontend/src/shell/notificationsView.test.mjs +35 -0
- package/template/server/package.json +5 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-astram-app",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Scaffolder for a new Astram app — emits a running, framework-enforced NestJS server (deny-by-default, built-in auth/identity to switch on) and, with --with-frontend, a React admin/auth UI, over the immutable @astram/* framework packages.",
|
|
6
6
|
"type": "module",
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
captchaVisible,
|
|
25
25
|
signInLabel,
|
|
26
26
|
} from '@/auth/signInOptions';
|
|
27
|
+
import { safeReturnPath } from '@astram/frontend-core';
|
|
27
28
|
import { loadReturnPath, clearReturnPath } from '@/platform/returnPathStore';
|
|
28
29
|
import { Button } from '@/components/ui/button';
|
|
29
30
|
import { Input } from '@/components/ui/input';
|
|
@@ -46,8 +47,10 @@ export default function Login() {
|
|
|
46
47
|
// Where to land after a successful login: the router's in-memory `from` (set when
|
|
47
48
|
// RequireAuth bounced the user this same page-session) if present, else the PERSISTED
|
|
48
49
|
// return path (survives a reload / explicit logout / browser restart — the OCA
|
|
49
|
-
// "return you where you left off" feature), else the dashboard.
|
|
50
|
-
|
|
50
|
+
// "return you where you left off" feature), else the dashboard. Every target passes
|
|
51
|
+
// safeReturnPath (loadReturnPath through decodeReturnPath), so only a same-origin in-app
|
|
52
|
+
// path is ever navigated to.
|
|
53
|
+
const from = safeReturnPath(location.state?.from) ?? loadReturnPath() ?? '/dashboard';
|
|
51
54
|
// Consume the persisted return path once we've captured it, so a later fresh login
|
|
52
55
|
// (deliberately hitting /login) doesn't resurrect a stale destination.
|
|
53
56
|
const goAfterLogin = (path) => {
|
|
@@ -86,15 +86,48 @@ export function taskSince(row, opts = {}) {
|
|
|
86
86
|
return parts.join(' · ');
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
// Unicode characters a URL parser or router could treat like `/` or `\`.
|
|
90
|
+
const SLASH_LOOKALIKES = /[⁄∕∖⧵⧸⧹﹨/\]/;
|
|
91
|
+
|
|
92
|
+
/** RFC 3986 §5.2.4 dot-segment removal for an absolute path (keeps empty segments). */
|
|
93
|
+
function removeDotSegments(absPath) {
|
|
94
|
+
const parts = absPath.split('/').slice(1);
|
|
95
|
+
const out = [];
|
|
96
|
+
parts.forEach((seg, i) => {
|
|
97
|
+
if (seg === '.' || seg === '..') {
|
|
98
|
+
if (seg === '..') out.pop();
|
|
99
|
+
if (i === parts.length - 1) out.push('');
|
|
100
|
+
} else {
|
|
101
|
+
out.push(seg);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
return '/' + out.join('/');
|
|
105
|
+
}
|
|
106
|
+
|
|
89
107
|
/**
|
|
90
|
-
* The notice link when it is safe to follow inside the app, else null.
|
|
91
|
-
* (`notification.service.ts` `validLink
|
|
92
|
-
* character, at most 512 characters
|
|
108
|
+
* The notice link when it is safe to follow inside the app, else null. The guard rule
|
|
109
|
+
* (`notification.service.ts` `validLink`: one leading `/` (never `//`), no backslash, no control
|
|
110
|
+
* character, at most 512 characters) plus a check on the form a router acts on: no `%2F` / `%5C`
|
|
111
|
+
* before the query, and after percent-decoding and resolving dot segments still one `/` followed
|
|
112
|
+
* by a character that is neither `/` nor `\`, with no backslash, control character or Unicode
|
|
113
|
+
* slash look-alike. A scheme can never follow a single leading `/`.
|
|
93
114
|
*/
|
|
94
115
|
export function safeAppLink(link) {
|
|
95
116
|
if (typeof link !== 'string' || link === '' || link.length > LINK_MAX) return null;
|
|
96
117
|
if (!link.startsWith('/') || link.startsWith('//')) return null;
|
|
97
|
-
if (link.includes('\\') || CONTROL_CHARS.test(link)) return null;
|
|
118
|
+
if (link.includes('\\') || CONTROL_CHARS.test(link) || SLASH_LOOKALIKES.test(link)) return null;
|
|
119
|
+
const rawPath = link.split(/[?#]/, 1)[0];
|
|
120
|
+
if (/%(2f|5c)/i.test(rawPath)) return null;
|
|
121
|
+
let decoded;
|
|
122
|
+
try {
|
|
123
|
+
decoded = decodeURIComponent(rawPath);
|
|
124
|
+
} catch {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
if (decoded.includes('\\') || CONTROL_CHARS.test(decoded) || SLASH_LOOKALIKES.test(decoded)) {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
if (removeDotSegments(decoded).startsWith('//')) return null;
|
|
98
131
|
return link;
|
|
99
132
|
}
|
|
100
133
|
|
|
@@ -111,6 +111,41 @@ describe('safeAppLink (the guard link rule)', () => {
|
|
|
111
111
|
assert.equal(safeAppLink(link), null, JSON.stringify(link));
|
|
112
112
|
}
|
|
113
113
|
});
|
|
114
|
+
test('paths that normalise or decode to another host are refused', () => {
|
|
115
|
+
for (const link of [
|
|
116
|
+
'/.//evil.example',
|
|
117
|
+
'/..//evil.example',
|
|
118
|
+
'/a/..//evil.example',
|
|
119
|
+
'/%2e%2e//evil.example',
|
|
120
|
+
'/%2F%2Fevil.example',
|
|
121
|
+
'/%2f/evil.example',
|
|
122
|
+
'/%5Cevil.example',
|
|
123
|
+
'/%5cevil.example',
|
|
124
|
+
'/%09/evil.example',
|
|
125
|
+
'/a%00b',
|
|
126
|
+
'/a%E2%88',
|
|
127
|
+
'/\evil.example',
|
|
128
|
+
'//evil.example',
|
|
129
|
+
'/∖evil.example',
|
|
130
|
+
'/∕evil.example',
|
|
131
|
+
'/﹨evil.example',
|
|
132
|
+
'/%EF%BC%BCevil.example',
|
|
133
|
+
]) {
|
|
134
|
+
assert.equal(safeAppLink(link), null, JSON.stringify(link));
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
test('encoded slashes after the path, dot segments inside it and non-ASCII names still pass', () => {
|
|
138
|
+
for (const link of [
|
|
139
|
+
'/search?next=%2Fimports',
|
|
140
|
+
'/imports/42#%2F',
|
|
141
|
+
'/imports/./42',
|
|
142
|
+
'/a/../imports',
|
|
143
|
+
'/files/résumé',
|
|
144
|
+
'/files/r%C3%A9sum%C3%A9',
|
|
145
|
+
]) {
|
|
146
|
+
assert.equal(safeAppLink(link), link, JSON.stringify(link));
|
|
147
|
+
}
|
|
148
|
+
});
|
|
114
149
|
test('empty, non-string and over-long ⇒ null', () => {
|
|
115
150
|
assert.equal(safeAppLink(''), null);
|
|
116
151
|
assert.equal(safeAppLink(null), null);
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@astram/guard": "0.29.0",
|
|
27
27
|
"@astram/guide": "^0.2.8",
|
|
28
28
|
"@astram/identity": "0.27.0",
|
|
29
|
-
"@astram/messaging": "0.1.
|
|
29
|
+
"@astram/messaging": "0.1.16",
|
|
30
30
|
"@astram/migrate": "0.7.6",
|
|
31
31
|
"@astram/sdk": "^0.2.0",
|
|
32
32
|
"@nestjs/common": "^11.2.7",
|
|
@@ -50,6 +50,9 @@
|
|
|
50
50
|
"vitest": "^2.1.8"
|
|
51
51
|
},
|
|
52
52
|
"overrides": {
|
|
53
|
-
"vitest": "$vitest"
|
|
53
|
+
"vitest": "$vitest",
|
|
54
|
+
"multer": "^2.5.0",
|
|
55
|
+
"body-parser": "^2.4.0",
|
|
56
|
+
"qs": "^6.17.1"
|
|
54
57
|
}
|
|
55
58
|
}
|