@caido-utils/backend 0.5.2 → 0.5.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.
@@ -1,4 +1,5 @@
1
1
  const STATIC_EXTENSIONS = [
2
+ // Images
2
3
  "apng",
3
4
  "avif",
4
5
  "gif",
@@ -14,17 +15,24 @@ const STATIC_EXTENSIONS = [
14
15
  "cur",
15
16
  "tif",
16
17
  "tiff",
18
+ // Stylesheets & fonts
17
19
  "css",
18
20
  "woff",
19
21
  "woff2",
20
22
  "ttf",
21
23
  "eot",
24
+ "otf",
25
+ // Scripts
22
26
  "js",
23
27
  "mjs",
24
28
  "jsx",
25
29
  "ts",
26
30
  "tsx",
31
+ // Source maps
27
32
  "map",
33
+ "js.map",
34
+ "css.map",
35
+ // Media
28
36
  "mp4",
29
37
  "webm",
30
38
  "ogg",
@@ -39,17 +47,34 @@ const STATIC_EXTENSIONS = [
39
47
  "flv",
40
48
  "mkv"
41
49
  ];
42
- const STATIC_ASSET_FILTER = STATIC_EXTENSIONS.map(
43
- (ext) => `req.ext.nlike:"%.${ext}"`
44
- ).join(" AND ");
50
+ const STATIC_CONTENT_TYPES = [
51
+ "Content-Type: image/",
52
+ "Content-Type: font/",
53
+ "Content-Type: application/javascript",
54
+ "Content-Type: text/javascript",
55
+ "Content-Type: text/css",
56
+ "Content-Type: application/x-javascript",
57
+ "Content-Type: application/font",
58
+ "Content-Type: application/x-font",
59
+ "Content-Type: audio/",
60
+ "Content-Type: video/"
61
+ ];
62
+ const STATIC_ASSET_FILTER = [
63
+ ...STATIC_EXTENSIONS.map((ext) => `req.ext.nlike:"%.${ext}"`),
64
+ ...STATIC_CONTENT_TYPES.map((ct) => `resp.raw.ncont:"${ct}"`)
65
+ ].join(" AND ");
45
66
  export async function queryRequests(sdk, options) {
46
67
  const pageSize = options?.pageSize ?? 1e3;
47
68
  const results = [];
48
69
  let cursor = void 0;
49
- let fullFilter = options?.filter ?? "";
70
+ const filters = ["resp.roundtrip.gt:0"];
71
+ if (options?.filter) {
72
+ filters.push(`(${options.filter})`);
73
+ }
50
74
  if (options?.excludeStaticAssets) {
51
- fullFilter = fullFilter ? `(${fullFilter}) AND ${STATIC_ASSET_FILTER}` : STATIC_ASSET_FILTER;
75
+ filters.push(STATIC_ASSET_FILTER);
52
76
  }
77
+ const fullFilter = filters.join(" AND ");
53
78
  while (true) {
54
79
  let query = sdk.requests.query().first(pageSize).ascending("req", "created_at");
55
80
  if (fullFilter) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caido-utils/backend",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"