@caido-utils/backend 0.5.1 → 0.5.3

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.
@@ -3,6 +3,7 @@ import type { RequestsConnectionItem } from "caido:utils";
3
3
  export type QueryRequestsOptions = {
4
4
  filter?: string;
5
5
  pageSize?: number;
6
+ excludeStaticAssets?: boolean;
6
7
  onPage?: (items: RequestsConnectionItem[]) => void;
7
8
  };
8
9
  /**
@@ -1,11 +1,84 @@
1
+ const STATIC_EXTENSIONS = [
2
+ // Images
3
+ "apng",
4
+ "avif",
5
+ "gif",
6
+ "jpg",
7
+ "jpeg",
8
+ "pjpeg",
9
+ "pjp",
10
+ "png",
11
+ "svg",
12
+ "webp",
13
+ "bmp",
14
+ "ico",
15
+ "cur",
16
+ "tif",
17
+ "tiff",
18
+ // Stylesheets & fonts
19
+ "css",
20
+ "woff",
21
+ "woff2",
22
+ "ttf",
23
+ "eot",
24
+ "otf",
25
+ // Scripts
26
+ "js",
27
+ "mjs",
28
+ "jsx",
29
+ "ts",
30
+ "tsx",
31
+ // Source maps
32
+ "map",
33
+ "js.map",
34
+ "css.map",
35
+ // Media
36
+ "mp4",
37
+ "webm",
38
+ "ogg",
39
+ "mp3",
40
+ "wav",
41
+ "flac",
42
+ "aac",
43
+ "m4a",
44
+ "avi",
45
+ "mov",
46
+ "wmv",
47
+ "flv",
48
+ "mkv"
49
+ ];
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.ncon:"${ct}"`)
65
+ ].join(" AND ");
1
66
  export async function queryRequests(sdk, options) {
2
67
  const pageSize = options?.pageSize ?? 1e3;
3
68
  const results = [];
4
69
  let cursor = void 0;
70
+ const filters = ["resp.roundtrip.gt:0"];
71
+ if (options?.filter) {
72
+ filters.push(`(${options.filter})`);
73
+ }
74
+ if (options?.excludeStaticAssets) {
75
+ filters.push(STATIC_ASSET_FILTER);
76
+ }
77
+ const fullFilter = filters.join(" AND ");
5
78
  while (true) {
6
79
  let query = sdk.requests.query().first(pageSize).ascending("req", "created_at");
7
- if (options?.filter) {
8
- query = query.filter(options.filter);
80
+ if (fullFilter) {
81
+ query = query.filter(fullFilter);
9
82
  }
10
83
  if (cursor !== void 0) {
11
84
  query = query.after(cursor);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caido-utils/backend",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"