Deleting data in Caido
WARNING
We do not recommend modifying the files directly as this might result in problems in the application and/or corruption of data. Proceed at your own risk.
Although we do not recommend doing this, we are aware that deleting data is not currently possible via the application. Thus we will go over some SQL commands you can run to clean it manually.
Please read our reference on internal files first to get familiar with the different files.
Finding the project
- Decide which project you want to clean.
- Navigate to your Caido data path.
- Open the projects database using
sqlite3 projects.db
. - Run
select * from projects;
and keep the UUID of the project you want to modify.
08c09bfa-a9fd-41e5-909e-2338a28319f9
Preparing the project database
- If Caido is running, kill the application.
- Navigate to
projects/<PROJECT UUID>/
. - Open the main data using
sqlite3 database.caido
- Switch to WAL mode:
PRAGMA main.journal_mode = WAL;
- Attach the raw database:
ATTACH DATABASE 'database_raw.caido' AS raw;
- Switch to WAL mode:
PRAGMA raw.journal_mode = WAL;
- Enable foreign keys:
PRAGMA foreign_keys = ON;
Do NOT skip the foreign keys step!!!
Deleting requests
The requests are stored in multiple tables and thus we need to be careful when cleaning them. The order of operations is important.
Determining requests & responses to delete
The first step is to find a list of requests we want to delete. We will keep that in a temporary table.
CREATE TEMP TABLE requests_to_delete AS
SELECT id, response_id
FROM requests
WHERE <your_condition_here> -- Replace with your condition
The condition could be, for example, host = "www.youtube.com"
.
CREATE TEMP TABLE responses_to_delete AS
WITH RECURSIVE recursive_responses AS (
SELECT r.id, r.parent_id
FROM responses r
INNER JOIN requests_to_delete rd ON r.id = rd.response_id
UNION ALL
SELECT r.id, r.parent_id
FROM responses r
INNER JOIN recursive_responses rr ON r.parent_id = rr.id
)
SELECT id FROM recursive_responses;
Cleaning requests raw
DELETE FROM requests_raw
WHERE id IN (
SELECT id
FROM requests_to_delete
);
Cleaning responses raw
DELETE FROM responses_raw
WHERE id IN (
SELECT id
FROM responses_to_delete
);
Cleaning sitemap entries
DELETE FROM sitemap_entries
WHERE request_id IN (
SELECT id
FROM requests_to_delete
);
Cleaning requests
This will also clean scoped_requests
and requests_metadata
.
DELETE FROM requests
WHERE id IN (
SELECT id
FROM requests_to_delete
);
Cleaning responses
DELETE FROM responses
WHERE id IN (
SELECT id
FROM responses_to_delete
);