appstage 0.2.23 → 0.2.25
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/dist/index.cjs +21 -5
- package/dist/index.mjs +21 -5
- package/package.json +1 -1
- package/src/controllers/files.ts +24 -16
package/dist/index.cjs
CHANGED
|
@@ -94,7 +94,11 @@ const files = (params) => {
|
|
|
94
94
|
if (!matches(urlPath, p.matches)) {
|
|
95
95
|
if (fallthrough) next();
|
|
96
96
|
else {
|
|
97
|
-
emitLog(req.app, "Unmatched path", {
|
|
97
|
+
emitLog(req.app, "Unmatched path", {
|
|
98
|
+
data: { urlPath },
|
|
99
|
+
req,
|
|
100
|
+
res
|
|
101
|
+
});
|
|
98
102
|
res.status(404).send(await req.app.renderStatus?.(req, res, {
|
|
99
103
|
code: "unmatched_path",
|
|
100
104
|
urlPath
|
|
@@ -105,7 +109,11 @@ const files = (params) => {
|
|
|
105
109
|
if (urlPath.includes("../")) {
|
|
106
110
|
if (fallthrough) next();
|
|
107
111
|
else {
|
|
108
|
-
emitLog(req.app, "Invalid path (potential traversal attempt)", {
|
|
112
|
+
emitLog(req.app, "Invalid path (potential traversal attempt)", {
|
|
113
|
+
data: { urlPath },
|
|
114
|
+
req,
|
|
115
|
+
res
|
|
116
|
+
});
|
|
109
117
|
res.status(400).send(await req.app.renderStatus?.(req, res, {
|
|
110
118
|
code: "invalid_path",
|
|
111
119
|
urlPath
|
|
@@ -123,20 +131,23 @@ const files = (params) => {
|
|
|
123
131
|
for (let k = 0; k < bases.length && filePath === null; k++) {
|
|
124
132
|
let base = bases[k];
|
|
125
133
|
if (!urlPath.endsWith("/")) {
|
|
126
|
-
for (let i = 0; i < suffixes.length && filePath === null; i++) filePath = await resolve(base, `${urlPath}${suffixes[i]}`);
|
|
127
134
|
if (filePath === null && urlExt) {
|
|
128
135
|
let urlPathBase = urlPath.slice(0, -urlExt.length);
|
|
129
136
|
for (let i = 0; i < suffixes.length && filePath === null; i++) filePath = await resolve(base, `${urlPathBase}${suffixes[i]}${urlExt}`);
|
|
130
137
|
}
|
|
138
|
+
for (let i = 0; i < suffixes.length && filePath === null; i++) filePath = await resolve(base, `${urlPath}${suffixes[i]}`);
|
|
131
139
|
for (let i = 0; i < suffixes.length && filePath === null; i++) for (let j = 0; j < exts.length && filePath === null; j++) filePath = await resolve(base, `${urlPath}${suffixes[i]}.${exts[j]}`);
|
|
132
140
|
}
|
|
133
|
-
for (let i = 0; i < suffixes.length && filePath === null; i++) for (let j = 0; j < exts.length && filePath === null; j++) filePath = await resolve(base, `${urlPath}${suffixes[i]}`, `index.${exts[j]}`);
|
|
134
141
|
for (let i = 0; i < suffixes.length && filePath === null; i++) for (let j = 0; j < exts.length && filePath === null; j++) filePath = await resolve(base, urlPath, `index${suffixes[i]}.${exts[j]}`);
|
|
135
142
|
}
|
|
136
143
|
if (filePath === null) {
|
|
137
144
|
if (fallthrough) next();
|
|
138
145
|
else {
|
|
139
|
-
emitLog(req.app, "Unknown path", {
|
|
146
|
+
emitLog(req.app, "Unknown path", {
|
|
147
|
+
data: { urlPath },
|
|
148
|
+
req,
|
|
149
|
+
res
|
|
150
|
+
});
|
|
140
151
|
res.status(404).send(await req.app.renderStatus?.(req, res, {
|
|
141
152
|
code: "unknown_path",
|
|
142
153
|
urlPath
|
|
@@ -144,6 +155,11 @@ const files = (params) => {
|
|
|
144
155
|
}
|
|
145
156
|
return;
|
|
146
157
|
}
|
|
158
|
+
emitLog(req.app, "File path resolved", {
|
|
159
|
+
data: { filePath },
|
|
160
|
+
req,
|
|
161
|
+
res
|
|
162
|
+
});
|
|
147
163
|
if (!p.transform?.length) {
|
|
148
164
|
res.sendFile(filePath);
|
|
149
165
|
return;
|
package/dist/index.mjs
CHANGED
|
@@ -68,7 +68,11 @@ const files = (params) => {
|
|
|
68
68
|
if (!matches(urlPath, p.matches)) {
|
|
69
69
|
if (fallthrough) next();
|
|
70
70
|
else {
|
|
71
|
-
emitLog(req.app, "Unmatched path", {
|
|
71
|
+
emitLog(req.app, "Unmatched path", {
|
|
72
|
+
data: { urlPath },
|
|
73
|
+
req,
|
|
74
|
+
res
|
|
75
|
+
});
|
|
72
76
|
res.status(404).send(await req.app.renderStatus?.(req, res, {
|
|
73
77
|
code: "unmatched_path",
|
|
74
78
|
urlPath
|
|
@@ -79,7 +83,11 @@ const files = (params) => {
|
|
|
79
83
|
if (urlPath.includes("../")) {
|
|
80
84
|
if (fallthrough) next();
|
|
81
85
|
else {
|
|
82
|
-
emitLog(req.app, "Invalid path (potential traversal attempt)", {
|
|
86
|
+
emitLog(req.app, "Invalid path (potential traversal attempt)", {
|
|
87
|
+
data: { urlPath },
|
|
88
|
+
req,
|
|
89
|
+
res
|
|
90
|
+
});
|
|
83
91
|
res.status(400).send(await req.app.renderStatus?.(req, res, {
|
|
84
92
|
code: "invalid_path",
|
|
85
93
|
urlPath
|
|
@@ -97,20 +105,23 @@ const files = (params) => {
|
|
|
97
105
|
for (let k = 0; k < bases.length && filePath === null; k++) {
|
|
98
106
|
let base = bases[k];
|
|
99
107
|
if (!urlPath.endsWith("/")) {
|
|
100
|
-
for (let i = 0; i < suffixes.length && filePath === null; i++) filePath = await resolve$1(base, `${urlPath}${suffixes[i]}`);
|
|
101
108
|
if (filePath === null && urlExt) {
|
|
102
109
|
let urlPathBase = urlPath.slice(0, -urlExt.length);
|
|
103
110
|
for (let i = 0; i < suffixes.length && filePath === null; i++) filePath = await resolve$1(base, `${urlPathBase}${suffixes[i]}${urlExt}`);
|
|
104
111
|
}
|
|
112
|
+
for (let i = 0; i < suffixes.length && filePath === null; i++) filePath = await resolve$1(base, `${urlPath}${suffixes[i]}`);
|
|
105
113
|
for (let i = 0; i < suffixes.length && filePath === null; i++) for (let j = 0; j < exts.length && filePath === null; j++) filePath = await resolve$1(base, `${urlPath}${suffixes[i]}.${exts[j]}`);
|
|
106
114
|
}
|
|
107
|
-
for (let i = 0; i < suffixes.length && filePath === null; i++) for (let j = 0; j < exts.length && filePath === null; j++) filePath = await resolve$1(base, `${urlPath}${suffixes[i]}`, `index.${exts[j]}`);
|
|
108
115
|
for (let i = 0; i < suffixes.length && filePath === null; i++) for (let j = 0; j < exts.length && filePath === null; j++) filePath = await resolve$1(base, urlPath, `index${suffixes[i]}.${exts[j]}`);
|
|
109
116
|
}
|
|
110
117
|
if (filePath === null) {
|
|
111
118
|
if (fallthrough) next();
|
|
112
119
|
else {
|
|
113
|
-
emitLog(req.app, "Unknown path", {
|
|
120
|
+
emitLog(req.app, "Unknown path", {
|
|
121
|
+
data: { urlPath },
|
|
122
|
+
req,
|
|
123
|
+
res
|
|
124
|
+
});
|
|
114
125
|
res.status(404).send(await req.app.renderStatus?.(req, res, {
|
|
115
126
|
code: "unknown_path",
|
|
116
127
|
urlPath
|
|
@@ -118,6 +129,11 @@ const files = (params) => {
|
|
|
118
129
|
}
|
|
119
130
|
return;
|
|
120
131
|
}
|
|
132
|
+
emitLog(req.app, "File path resolved", {
|
|
133
|
+
data: { filePath },
|
|
134
|
+
req,
|
|
135
|
+
res
|
|
136
|
+
});
|
|
121
137
|
if (!p.transform?.length) {
|
|
122
138
|
res.sendFile(filePath);
|
|
123
139
|
return;
|
package/package.json
CHANGED
package/src/controllers/files.ts
CHANGED
|
@@ -107,7 +107,11 @@ export const files: Controller<string | FilesParams> = (params) => {
|
|
|
107
107
|
if (!matches(urlPath, p.matches)) {
|
|
108
108
|
if (fallthrough) next();
|
|
109
109
|
else {
|
|
110
|
-
emitLog(req.app, "Unmatched path", {
|
|
110
|
+
emitLog(req.app, "Unmatched path", {
|
|
111
|
+
data: { urlPath },
|
|
112
|
+
req,
|
|
113
|
+
res,
|
|
114
|
+
});
|
|
111
115
|
|
|
112
116
|
res.status(404).send(
|
|
113
117
|
await req.app.renderStatus?.(req, res, {
|
|
@@ -125,6 +129,8 @@ export const files: Controller<string | FilesParams> = (params) => {
|
|
|
125
129
|
else {
|
|
126
130
|
emitLog(req.app, "Invalid path (potential traversal attempt)", {
|
|
127
131
|
data: { urlPath },
|
|
132
|
+
req,
|
|
133
|
+
res,
|
|
128
134
|
});
|
|
129
135
|
|
|
130
136
|
res.status(400).send(
|
|
@@ -156,10 +162,6 @@ export const files: Controller<string | FilesParams> = (params) => {
|
|
|
156
162
|
let base = bases[k];
|
|
157
163
|
|
|
158
164
|
if (!urlPath.endsWith("/")) {
|
|
159
|
-
// /x.en /x /x.ru
|
|
160
|
-
for (let i = 0; i < suffixes.length && filePath === null; i++)
|
|
161
|
-
filePath = await resolve(base, `${urlPath}${suffixes[i]}`);
|
|
162
|
-
|
|
163
165
|
if (filePath === null && urlExt) {
|
|
164
166
|
let urlPathBase = urlPath.slice(0, -urlExt.length);
|
|
165
167
|
|
|
@@ -171,6 +173,10 @@ export const files: Controller<string | FilesParams> = (params) => {
|
|
|
171
173
|
);
|
|
172
174
|
}
|
|
173
175
|
|
|
176
|
+
// /x.en /x /x.ru
|
|
177
|
+
for (let i = 0; i < suffixes.length && filePath === null; i++)
|
|
178
|
+
filePath = await resolve(base, `${urlPath}${suffixes[i]}`);
|
|
179
|
+
|
|
174
180
|
// /x.en.html /x.en.htm /x.html /x.htm /x.ru.html /x.ru.htm
|
|
175
181
|
for (let i = 0; i < suffixes.length && filePath === null; i++) {
|
|
176
182
|
for (let j = 0; j < exts.length && filePath === null; j++)
|
|
@@ -181,16 +187,6 @@ export const files: Controller<string | FilesParams> = (params) => {
|
|
|
181
187
|
}
|
|
182
188
|
}
|
|
183
189
|
|
|
184
|
-
// /x.en/index.html /x.en/index.htm /x/index.html /x/index.htm /x.ru/index.html /x.ru/index.htm
|
|
185
|
-
for (let i = 0; i < suffixes.length && filePath === null; i++) {
|
|
186
|
-
for (let j = 0; j < exts.length && filePath === null; j++)
|
|
187
|
-
filePath = await resolve(
|
|
188
|
-
base,
|
|
189
|
-
`${urlPath}${suffixes[i]}`,
|
|
190
|
-
`index.${exts[j]}`,
|
|
191
|
-
);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
190
|
// /x/index.en.html /x/index.en.htm /x/index.html /x/index.htm /x/index.ru.html /x/index.ru.htm
|
|
195
191
|
for (let i = 0; i < suffixes.length && filePath === null; i++) {
|
|
196
192
|
for (let j = 0; j < exts.length && filePath === null; j++)
|
|
@@ -205,7 +201,11 @@ export const files: Controller<string | FilesParams> = (params) => {
|
|
|
205
201
|
if (filePath === null) {
|
|
206
202
|
if (fallthrough) next();
|
|
207
203
|
else {
|
|
208
|
-
emitLog(req.app, "Unknown path", {
|
|
204
|
+
emitLog(req.app, "Unknown path", {
|
|
205
|
+
data: { urlPath },
|
|
206
|
+
req,
|
|
207
|
+
res,
|
|
208
|
+
});
|
|
209
209
|
|
|
210
210
|
res.status(404).send(
|
|
211
211
|
await req.app.renderStatus?.(req, res, {
|
|
@@ -218,6 +218,14 @@ export const files: Controller<string | FilesParams> = (params) => {
|
|
|
218
218
|
return;
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
+
emitLog(req.app, "File path resolved", {
|
|
222
|
+
data: {
|
|
223
|
+
filePath,
|
|
224
|
+
},
|
|
225
|
+
req,
|
|
226
|
+
res,
|
|
227
|
+
});
|
|
228
|
+
|
|
221
229
|
if (!p.transform?.length) {
|
|
222
230
|
res.sendFile(filePath);
|
|
223
231
|
return;
|