-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: pre compute breached passwords (#37)
* feat: use dependency injection with callback function The database class should be implementation-agnostic, so the execute function needs to support arbitrary callbacks. There are currently two versions of execute in the event the user does not care about the result (e.g. when inserting), but a default value in the templated version is a sound alternative. The templated version is defined within the header file for C++ compiler reasons. The alternative is to explcitly define each possible ttype of T in the source file; right now, the only value is std::string, but this doesn't seem idiomatic. * fix: finalize SQlite statment after iteration * test: test Database class * fix: include vector in database.hpp * fix: include functional in database.hpp * test: use variable for path * docs: add some TODO statements * refactor: update cryptography test name * chore: update .gitignore * feat: allow rebuilding the database using command line * test: test allowing rebuild * build: remove make run from Makefile One or more command line arguments are now required. Use the command build/src/server build/passwords.db to achieve (almost) the same result as make run. * feat: adding logging * fix: only create table when rebuilding * docs: add comments for functions * fix: only abort if close fails * docs: add some TODO statements * feat: encode the encrypted breached passwords before inserting into the database * feat: use database for breached passwords * refactor: change rebuild flag to build and improve error handling * docs: update build instructions in readme * feat: wip store secret key b BREAKING CHANGE: trying to figure out how to properly retrieve value from secret key table * feat: insert key b into database so the user password can be encrypted with the same b as the breached passwords * test: fix the endpoint handler test by creating a table for the secret key b and storing the key * test: test that using the build flag on a populated database will produce a new empty database * test: test the contents of the names remain the same after reopening a database with the same file and build as default false BREAKING CHANGE: when the database file is initialized and reopened in the same test section then it passes, but not when the database file is reopened in a different section than initialization * refactor: use global variables for database tests * docs: update readmes: * docs: explain the --build flag in the private-data-lookup/README.md * docs: encourage the use of /data directory for databases * docs: use build instead of rebuild in constructor comment * refactor: move the code from the open() method in Database class to inside the Database constructor * refactor: throw invalid argument for an incorrect filepath instead of a runtime error * refactor: use snack_case for variables encoded_b and decoded_b * refactor: rename results vector to breached_passwords for readability * refactor: return the count of querying names tables instead of a boolean of the if the table exists * refactor: return the counts of the query rather than a boolean * docs: change description tense of test case * test: create own string list of passwords instead of using generatePasswords() * feat: add input sanitization to make sure the file ends in .db * refactor: use catch2 nested sections for database tests * feat: error check if the passwords table does not exist in the file passed in * refactor: throw runtime error rather than abort if the database can not close properly * refactor: remove encodePasswords() helper method * refactor: use abort instead of throwing error due to deconstructer conventions * feat: print error message in deconstructor * refactor: update import statements * refactor: improve database error handling * feat: use spdlog::error instead of print stderr * refactor: remove unused open definition * test: use int in std::function * docs: remove inline comment --------- Co-authored-by: Cedric Sirianni <[email protected]> Co-authored-by: stellaljung <[email protected]>
- Loading branch information
1 parent
4368acd
commit b9d8751
Showing
16 changed files
with
327 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
/build | ||
CMakeUserPresets.json | ||
CMakeUserPresets.json | ||
*.db | ||
/data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
find_package(Crow REQUIRED) | ||
find_package(SQLite3 REQUIRED) | ||
find_package(libsodium REQUIRED) | ||
find_package(spdlog REQUIRED) | ||
|
||
add_library(src database.cpp password.cpp server.cpp cryptography.cpp) | ||
target_link_libraries(src Crow::Crow libsodium::libsodium) | ||
target_link_libraries(src Crow::Crow libsodium::libsodium spdlog::spdlog) | ||
|
||
add_executable(server main.cpp) | ||
target_link_libraries(server Crow::Crow SQLite::SQLite3 libsodium::libsodium src) | ||
target_link_libraries(server Crow::Crow SQLite::SQLite3 libsodium::libsodium spdlog::spdlog src) | ||
target_include_directories(server PRIVATE src) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.