The push functionality allows users to synchronize their local shell history to the backend via the CLI. This ensures efficient storage, prevents duplication of commands, and selectively excludes irrelevant commands. It leverages SQLite for local storage and MongoDB for backend persistence.
Scope
Backend
Endpoint: Implement a POST /push API endpoint to receive shell history.
Authentication: Authenticate users using JWT tokens and their email addresses.
Data Storage: Push shell history to the user's history collection in MongoDB, ensuring no duplication of records.
CLI
Local History Parsing: Read and filter the .bash_history file on the user’s system, removing unwanted commands like cd, ls, and pwd.
Deduplication: Ensure that only new, unsynced commands are pushed by checking against the local SQLite database and the backend MongoDB.
Local Storage: Store commands locally in SQLite until they are successfully pushed to the backend.
Excluded Commands
Commands such as cd, ls, pwd, and others that do not provide significant value for synchronization will be excluded using a predefined list or user-defined exclusion rules.
Tests
Unit Tests: Ensure that the backend controller and CLI history pushing modules work correctly.
Technical Details
Backend
Controller: A new pushController will be created to process the POST /history/push requests and handle the synchronization logic.
User Model: Extend the userModel in MongoDB to store shell history in a history field, linking the history to individual users.
Authentication Middleware: Secure the push API with JWT-based authentication, ensuring only authorized users can push data.
CLI
SQLite Management: Use SQLite for efficient local storage of shell history, ensuring commands are cached until they are successfully pushed.
Token Storage: Enhance tokenStorage to store the user's email for secure backend requests.
History Filtering: Implement a utility module to filter out commands based on predefined exclusion patterns and remove duplicates before pushing.
Acceptance Criteria
Users can seamlessly push their local shell history to the backend through the CLI.
The system ensures that no duplicate history is pushed, by checking both local and backend records.
Commands that are irrelevant (e.g., cd, ls) are excluded during history parsing.
Push Command Feature
Description
The
push
functionality allows users to synchronize their local shell history to the backend via the CLI. This ensures efficient storage, prevents duplication of commands, and selectively excludes irrelevant commands. It leverages SQLite for local storage and MongoDB for backend persistence.Scope
Backend
POST /push
API endpoint to receive shell history.CLI
Excluded Commands
Commands such as
cd, ls, pwd
, and others that do not provide significant value for synchronization will be excluded using a predefined list or user-defined exclusion rules.Tests
Technical Details
Backend
pushController
will be created to process the POST /history/push requests and handle the synchronization logic.userModel
in MongoDB to store shell history in a history field, linking thehistory
to individual users.push
API with JWT-based authentication, ensuring only authorized users can push data.CLI
tokenStorage
to store the user's email for secure backend requests.Acceptance Criteria