Skip to content

Commit

Permalink
Filtering (#25)
Browse files Browse the repository at this point in the history
* Hacky solution to fix filtering

* Update SDK and use HTTPQL api to filter reuqests
  • Loading branch information
Splinter0 authored Nov 3, 2024
1 parent 297ea90 commit 6456d8b
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 28 deletions.
2 changes: 1 addition & 1 deletion packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"shared": "workspace:*"
},
"devDependencies": {
"@caido/sdk-backend": "0.42.0"
"@caido/sdk-backend": "0.43.1"
}
}
5 changes: 5 additions & 0 deletions packages/backend/src/services/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ export const onInterceptResponse = async (
if (settings.autoCaptureRequests == "off") {
return;
}

if (!sdk.requests.matches(settings.defaultFilterHTTPQL, request)) {
sdk.console.log(`Filtering: ${request.getUrl()}`)
return;
}

const templateId = generateTemplateId(request, settings.deDuplicateHeaders);
if (store.templateExists(templateId)) {
Expand Down
6 changes: 6 additions & 0 deletions packages/backend/src/stores/settings.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import type { SettingsDTO } from "shared";

const noStylingFilter: string = `req.ext.nlike:"%.css" AND req.ext.nlike:"%.woff" AND req.ext.nlike:"%.woff2" AND req.ext.nlike:"%.ttf" AND req.ext.nlike:"%.eot"`;
const noImagesFilter: string = `req.ext.nlike:"%.apng" AND req.ext.nlike:"%.avif" AND req.ext.nlike:"%.gif" AND req.ext.nlike:"%.jpg" AND req.ext.nlike:"%.jpeg" AND req.ext.nlike:"%.pjpeg" AND req.ext.nlike:"%.pjp" AND req.ext.nlike:"%.png" AND req.ext.nlike:"%.svg" AND req.ext.nlike:"%.webp" AND req.ext.nlike:"%.bmp" AND req.ext.nlike:"%.ico" AND req.ext.nlike:"%.cur" AND req.ext.nlike:"%.tif" AND req.ext.nlike:"%.tiff"`;
const noJSFilter: string = `req.ext.nlike:"%.js"`

export class SettingsStore {
private static _store?: SettingsStore;

private settings: SettingsDTO;


private constructor() {
this.settings = {
autoCaptureRequests: "off",
autoRunAnalysis: true,
deDuplicateHeaders: [],
defaultFilterHTTPQL: `(${noStylingFilter} AND ${noImagesFilter} AND ${noJSFilter})`,
};
}

Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"dependencies": {
"@caido/primevue": "0.1.1",
"@caido/sdk-frontend": "0.42.0",
"@caido/sdk-frontend": "0.43.1",
"@fortawesome/fontawesome-free": "6.6.0",
"@vueuse/core": "10.11.1",
"pinia": "2.2.1",
Expand All @@ -20,7 +20,7 @@
"vue": "3.4.37"
},
"devDependencies": {
"@caido/sdk-backend": "0.42.0",
"@caido/sdk-backend": "0.43.1",
"@caido/tailwindcss": "0.0.1",
"@codemirror/view": "6.28.1",
"@vitejs/plugin-vue": "5.1.2",
Expand Down
1 change: 1 addition & 0 deletions packages/shared/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export type SettingsDTO = {
autoCaptureRequests: "off" | "all" | "inScope";
autoRunAnalysis: boolean;
deDuplicateHeaders: string[];
defaultFilterHTTPQL: string;
};

export type UserAttributeDTO = {
Expand Down
41 changes: 16 additions & 25 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6456d8b

Please sign in to comment.