create-astram-app 0.14.3 → 0.14.5
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/docker-compose.analyser.yml +49 -0
- package/template/frontend/package.json +1 -1
- package/template/frontend/src/pages/Login.jsx +5 -2
- package/template/frontend/src/platform/agentStreamTransport.test.mjs +15 -0
- package/template/frontend/src/shell/notificationsView.js +37 -4
- package/template/frontend/src/shell/notificationsView.test.mjs +35 -0
- package/template/server/_env.example +10 -0
- package/template/server/package.json +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-astram-app",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.5",
|
|
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",
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# The isolated file analyser for the AI assistant's file reads (@astram/agent, G-037 D2a).
|
|
2
|
+
#
|
|
3
|
+
# Only needed when server/src/app.module.ts imports AgentModule.forRoot({ files: { enabled: true } }).
|
|
4
|
+
# Every attached file (xlsx, csv, pdf, docx) is parsed here, never in the app server: no network,
|
|
5
|
+
# read-only filesystem, no capabilities, fixed limits, one worker process per call. Only the app
|
|
6
|
+
# server talks to it, over a unix socket in a shared volume.
|
|
7
|
+
#
|
|
8
|
+
# Add this to your deployment next to the app server, e.g.
|
|
9
|
+
# docker compose -f docker-compose.yml -f docker-compose.analyser.yml up -d
|
|
10
|
+
# The image is built from the npm package (install it in server/: `npm i @astram/file-analyser`);
|
|
11
|
+
# hosts without a container runtime use the package's systemd unit instead
|
|
12
|
+
# (node_modules/@astram/file-analyser/deploy/astram-file-analyser.service).
|
|
13
|
+
|
|
14
|
+
services:
|
|
15
|
+
astram-file-analyser:
|
|
16
|
+
build:
|
|
17
|
+
context: ./server/node_modules/@astram/file-analyser
|
|
18
|
+
image: astram-file-analyser:0.1.0
|
|
19
|
+
restart: unless-stopped
|
|
20
|
+
# No network at all, and no ports: the app reaches it only through the socket volume.
|
|
21
|
+
network_mode: none
|
|
22
|
+
read_only: true
|
|
23
|
+
cap_drop: [ALL]
|
|
24
|
+
# Docker's default seccomp profile stays on: never add `seccomp:unconfined`.
|
|
25
|
+
security_opt: [no-new-privileges:true]
|
|
26
|
+
mem_limit: 1g
|
|
27
|
+
memswap_limit: 1g
|
|
28
|
+
cpus: 1
|
|
29
|
+
pids_limit: 64
|
|
30
|
+
volumes:
|
|
31
|
+
- astram-analyser-sock:/run/astram-analyser
|
|
32
|
+
|
|
33
|
+
# Add to YOUR app server's service (its name in your compose file), not as a new service:
|
|
34
|
+
#
|
|
35
|
+
# server:
|
|
36
|
+
# # The socket directory is mode 0700, owned by the analyser's uid/gid 10001 (set in its
|
|
37
|
+
# # Dockerfile), so the app container must run as that same uid/gid to open the socket.
|
|
38
|
+
# user: '10001:10001'
|
|
39
|
+
# volumes:
|
|
40
|
+
# - astram-analyser-sock:/run/astram-analyser
|
|
41
|
+
# environment:
|
|
42
|
+
# AGENT_FILE_ANALYSER_SOCKET: /run/astram-analyser/analyser.sock
|
|
43
|
+
# AGENT_FILE_ANALYSER_TIMEOUT_MS: '12000'
|
|
44
|
+
# depends_on: [astram-file-analyser]
|
|
45
|
+
|
|
46
|
+
volumes:
|
|
47
|
+
# Holds only the analyser's socket. A new named volume takes the image directory's owner
|
|
48
|
+
# (10001) and mode (0700); nothing else mounts it.
|
|
49
|
+
astram-analyser-sock:
|
|
@@ -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) => {
|
|
@@ -76,6 +76,21 @@ describe('createAgentStreamTransport', () => {
|
|
|
76
76
|
assert.equal(calls[0].init.body, '{"message":"Hi"}');
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
+
test('an attachments list in the body is sent as given (agent-file-read §3)', async () => {
|
|
80
|
+
const { fetchImpl, calls } = fetchSeq(sseResponse([FRAME]));
|
|
81
|
+
const t = createAgentStreamTransport({ getToken: () => 'tok-1', fetchImpl });
|
|
82
|
+
const attachments = ['0b9f8c7e-1d2a-4b3c-8d4e-5f6a7b8c9d0e'];
|
|
83
|
+
const res = await t.open({
|
|
84
|
+
method: 'POST',
|
|
85
|
+
path: '/agent/tasks/task_x/continue',
|
|
86
|
+
body: { message: 'Profile it', attachments },
|
|
87
|
+
signal: signal(),
|
|
88
|
+
});
|
|
89
|
+
assert.equal(res.status, 200);
|
|
90
|
+
await readAll(res.chunks);
|
|
91
|
+
assert.deepEqual(JSON.parse(calls[0].init.body), { message: 'Profile it', attachments });
|
|
92
|
+
});
|
|
93
|
+
|
|
79
94
|
test('GET replay sends Last-Event-ID and no body', async () => {
|
|
80
95
|
const { fetchImpl, calls } = fetchSeq(sseResponse([]));
|
|
81
96
|
const t = createAgentStreamTransport({ getToken: () => 'tok-1', fetchImpl });
|
|
@@ -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);
|
|
@@ -182,6 +182,16 @@ NODE_ENV=development
|
|
|
182
182
|
# INVITE_LINK_TTL_HOURS=72
|
|
183
183
|
# INVITE_RATE_PER_ADMIN=30
|
|
184
184
|
|
|
185
|
+
# --- OPTIONAL: AI assistant file reading (@astram/agent, G-037 D2a) ---
|
|
186
|
+
# Read once at boot, and only when the app imports AgentModule.forRoot({ files: { enabled: true } })
|
|
187
|
+
# (this template does not wire AgentModule; files are off by default and nothing below is read).
|
|
188
|
+
# Every attached file is parsed by the isolated analyser (@astram/file-analyser), never by this
|
|
189
|
+
# server: run it as the sidecar in ../docker-compose.analyser.yml or as its systemd unit.
|
|
190
|
+
# Absolute path of the analyser's unix socket (required when files are on).
|
|
191
|
+
# AGENT_FILE_ANALYSER_SOCKET=/run/astram-analyser/analyser.sock
|
|
192
|
+
# Per-call bound in ms (default 12000, 1000-60000); a slower call fails closed.
|
|
193
|
+
# AGENT_FILE_ANALYSER_TIMEOUT_MS=12000
|
|
194
|
+
|
|
185
195
|
# --- OPTIONAL: release name for the permission catalog ---
|
|
186
196
|
# Stamped once on each permission key the catalog first sees (with the date), so admins can tell
|
|
187
197
|
# which release added it. 1-64 characters of letters, digits, . _ + - (a git tag or sha fits);
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@astram/core": "1.16.0",
|
|
25
25
|
"@astram/engine": "0.17.1",
|
|
26
|
-
"@astram/guard": "0.
|
|
26
|
+
"@astram/guard": "0.30.0",
|
|
27
27
|
"@astram/guide": "^0.2.8",
|
|
28
|
-
"@astram/identity": "0.
|
|
29
|
-
"@astram/messaging": "0.1.
|
|
28
|
+
"@astram/identity": "0.28.0",
|
|
29
|
+
"@astram/messaging": "0.1.17",
|
|
30
30
|
"@astram/migrate": "0.7.6",
|
|
31
31
|
"@astram/sdk": "^0.2.0",
|
|
32
32
|
"@nestjs/common": "^11.2.7",
|