You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* porting sqlite operations to APSW and making necessary changes with unittests for db.py
* ruff fixes
* ruff fixes 2.0
* improved test_db.py
* ruff fixes
* fix for subdomains
* ruff
* updated poetry lock and merged master
* fixing test_db.py, the other one is still failing because of some mocking issues
* fixing tests
* poetry lock updates
* bot suggestions
* update documentation for databases
* spelling fix
* docstring update
* added logic to toggle between APSW and SQLAlchemy for sqlite databases for backward compatibility
* updated docs
* bug fixing
* coderabbit suggested changes and test fixes
* coderabbit suggested changes
* closing connections if no targets are present
* added new parameter for retires in config and ensured closure of all connections
* triple quotes preserve whitespaces which causes indentation issues in tests and make them more fragile
* some bug fixes
* removed unncessary file
* error handling
* Update code
* some formatting changes
* removing report
* used context managers for file opens in db.py and updated test to handle __enter__ (as earlier we didn't have to)
* fix: removing duplicate python instance
* fixed lock file
---------
Signed-off-by: Achintya Jai <153343775+pUrGe12@users.noreply.github.com>
Co-authored-by: Arkadii Yakovets <arkadii.yakovets@owasp.org>
OWASP Nettacker, currently supports two databases:
650
-
- SQLite
649
+
650
+
OWASP Nettacker, currently supports three databases:
651
+
651
652
- MySQL
653
+
- PostgreSQL
654
+
- SQLite
655
+
652
656
The default database is SQLite. You can, however, configure the db to your liking.
657
+
653
658
## SQLite configuration
654
-
The SQLite database can be configured in `core/config.py` file under the `_database_config()` function. Here is a sample configuration:
655
-
```
656
-
return {
657
-
"DB": "sqlite",
658
-
"DATABASE": _paths()["home_path"] + "/nettacker.db", # This is the location of your db
659
-
"USERNAME": "",
660
-
"PASSWORD": "",
661
-
"HOST": "",
662
-
"PORT": ""
663
-
}
659
+
660
+
The configurations below are for a SQLite wrapper called **APSW** (Another Python SQLite Wrapper). The configurations can be found inside `nettacker/config.py` file under the `DBConfig` class.
661
+
662
+
```python
663
+
engine ="sqlite"
664
+
name =str(CWD/".nettacker/data/nettacker.db")
665
+
host =""
666
+
port =""
667
+
username =""
668
+
password =""
669
+
ssl_mode ="disable"
670
+
journal_mode ="WAL"
671
+
synchronous_mode ="NORMAL"
664
672
```
673
+
674
+
These are the default and recommended settings. Feel free to play around and change them according to need. To use SQLite database, ensure that the `engine` value is set to `sqlite` and the `name` is the path to your database. The `journal_mode` and `synchronous_mode` are chosen to be optimal for multithreaded I/O operations.
675
+
676
+
> Note: You can choose to use a lite wrapper for Sqlite called APSW by setting the `use_apsw_for_sqlite` parameter inside config to True for performance enhancements.
677
+
665
678
## MySQL configuration:
666
-
The MySQL database can be configured in `core/config.py` file under the `_database_config()` function. Here is a sample configuration:
667
-
```
668
-
return {
669
-
"DB": "mysql",
670
-
"DATABASE": "nettacker", # This is the name of your db
671
-
"USERNAME": "username",
672
-
"PASSWORD": "password",
673
-
"HOST": "localhost or some other host",
674
-
"PORT": "3306 or some other custom port"
675
-
}
676
-
```
677
-
After this configuration:
678
-
1. Open the configuration file of mysql(`/etc/mysql/my.cnf` in case of linux) as a sudo user
The MySQL database can be configured in `nettacker/config.py` file under the `DBConfig` class. Here is a sample configuration:
681
+
682
+
```python
683
+
engine ="mysql"
684
+
name ="nettacker"
685
+
host ="localhost"
686
+
port =3306
687
+
username ="root"
688
+
password ="some-password"
689
+
ssl_mode ="disable"
690
+
journal_mode ="WAL"
691
+
synchronous_mode ="NORMAL"
683
692
```
684
-
3. Restart MySQL
693
+
694
+
Only the relevant fields will be considered and you don't need to update/change/remove the irrelevant ones (`ssl_mode`, `journal_mode` and `synchronous_mode` aren't relevant in this case).
685
695
686
696
## Postgres Configuration
687
697
688
-
The Postgres database can be configured in core/config.py file under the _database_config() function. Here is a sample configuration:
689
-
`
690
-
return {
691
-
"DB": "postgreas",
692
-
"DATABASE": "nettacker" # Name of db
693
-
"USERNAME": "username",
694
-
"PASSWORD": "password",
695
-
"HOST": "localhost or some other host",
696
-
"PORT": "5432 or some other custom port"
697
-
}
698
-
`
699
-
After this configuration please comment out the following line in database/db.py `connect_args={'check_same_thread': False}`
698
+
The Postgres database can be configured in `nettacker/config.py` file under the `DBConfig` class. Here is a sample configuration:
699
+
700
+
```python
701
+
engine ="postgres"
702
+
name ="nettacker"
703
+
host ="localhost"
704
+
port =5432
705
+
username ="root"
706
+
password ="some-password"
707
+
ssl_mode ="disable"
708
+
journal_mode ="WAL"
709
+
synchronous_mode ="NORMAL"
710
+
```
700
711
712
+
In this case the irrelevant fields are `journal_mode` and `synchronous_mode`. You don't have to update/change/remove them.
701
713
714
+
**Note**: If you want encryption, then set `ssl_mode` to `require`.
0 commit comments