rm the db-bak, added a few source files
This commit is contained in:
122
sources/notes.md
122
sources/notes.md
@@ -2,3 +2,125 @@
|
||||
- Use full variable names in the new tests.
|
||||
- Review all tests in the test files edited or created; refactor the tests using dry-principle.md.
|
||||
|
||||
===
|
||||
|
||||
None of the items on the scanner's list expose anything in production; they're all false positives or test data. But the folder does hold one real risk the list doesn't name: a tracked database backup containing working admin logins.
|
||||
|
||||
The listed items
|
||||
|
||||
┌─────────────────────────┬─────────────────────┬─────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
│ Category │ Verdict │ Why │
|
||||
├─────────────────────────┼─────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ API key sk_/pk_/api_ │ False positive │ Every hit is an import line. The text api_ appears in module names like │
|
||||
│ (7) │ │ api_object_data_permissions_v0. │
|
||||
├─────────────────────────┼─────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ HashiCorp Vault token │ │ This is the vendored TinyMCE editor library. Its minified code has strings like │
|
||||
│ (2) │ False positive │ s.stopImmediatePropagation that look like the old Vault token format s.xxxx. No real token is │
|
||||
│ │ │ in there. │
|
||||
├─────────────────────────┼─────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Password passed to a │ False positive │ The matches are Vue item-key="kanban_card_id" attributes. │
|
||||
│ command (3) │ │ │
|
||||
├─────────────────────────┼─────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ Password/key/token in │ False positive (4) │ models.py and the two migrations match on default=uuid.uuid4. The 16 test files set password = │
|
||||
│ code (20) │ / test data (16) │ "Test1234$", the test-suite password. │
|
||||
├─────────────────────────┼─────────────────────┼────────────────────────────────────────────────────────────────────┤
|
||||
│ Email addresses (20) │ Not sensitive │ Project role addresses (support@, noreply@), made-up test domains (nearbeahc.org, │ │ │ fardesert.oks like a real person's data. │
|
||||
└─────────────────────────┴─────────────────────┴─────────────────────────────────────────────────────────────────────────────────────────────────┘
|
||||
Real exposure risks the list doesn't spell out
|
||||
These were probably among the "more were found" hits.
|
||||
1. db.sqlite3-bak: high. It's a 1.2 MB SQLite backup, and git tracks it. It contains: - 8 users, 2 of them superusers (admin, dark_admin). All ecked each stored hash.
|
||||
- A 2FA (TOTP) device record including its secret key. I didn't print the key. - 36 sessions and 8 knox token digests. All of them expirores only digests, so none can be reused directly.
|
||||
- 5 document records and 1 customer, all demo data.
|
||||
It isn't shipped in the package, because MANIFEST.in only includes NearBeach/*. The danger is someone renaming it to db.sqlite3 and deploying: that site would have known superuser logins on day one. My recrom the repo. I didn't delete it because that's your call.
|
||||
2. Hardcoded SECRET_KEY in local/settings.py:26: medium. It's labelled as test-only settings. But anyone who copies this file to start a deployment inherits a public signing key, which lets an attacker forinks and other signed values.
|
||||
3. Fixture superusers with known passwords: low to medium. All 15 accounts across the three files in NearBeach/fixtures/ use Test1234$, including 4 superusers. Unlike the backup, these files are shipped in harm if someone runs loaddata against a production database,but that's an easy mistake to make.
|
||||
For the scanner design
|
||||
This is a useful test set for the CLI we discussed. It shows that matching on text patterns alone produces a lot of noise: 32 of the 52 listed hits were false positives. Three rules would have found the real
|
||||
- tracked database or backup files;
|
||||
- SECRET_KEY written in as a literal value;
|
||||
- fixture files with superusers that have a known or weak password.
|
||||
|
||||
===
|
||||
|
||||
❯ how do I run NearBeach/?
|
||||
|
||||
Thought for 25s, ran 4 shell commands
|
||||
|
||||
You can run it locally with Django's development server; no Docker needed. Your machine already has Python 3.11 and Node 24, and the compiled frontend files are committed, so you don't need npm. I haven't run any of this; it comes from the project's setup docs (docs/002-local-development-environment-setup/index.rst) and from reading the code.
|
||||
|
||||
cd /home/eric/workspaces/dataannotation/project-6/NearBeach
|
||||
|
||||
python3 -m venv venv
|
||||
source venv/bin/activate
|
||||
pip install -r requirements-dev.txt
|
||||
|
||||
python manage.py migrate # creates a fresh db.sqlite3
|
||||
python manage.py createsuperuser
|
||||
python manage.py runserver
|
||||
|
||||
Then open http://localhost:8000/login (the Django admin is at /admin/).
|
||||
|
||||
Things that will trip you up
|
||||
|
||||
- Use localhost, not 127.0.0.1. ALLOWED_HOSTS in local/settings.py lists localhost, 0.0.0.0 and 192.168.1.105. Going to 127.0.0.1 gives a
|
||||
"DisallowedHost" error. The docs suggest editing the settiot to commit changes to it, so using localhost avoids theproblem.
|
||||
- The first login does extra setup. Logging in with a user tts you logged straight out. The first login also runsinitalize_base_values, which creates the permission sets, an admin group with your user in it, and a "No Organisation" record. A fresh superuser
|
||||
should therefore get in, but other users need adding to a
|
||||
- Skip manage.py initaliazeobjects. It calls User.objects.get(is_admin=True).first(), which fails because User has no is_admin field and .first()
|
||||
doesn't work on a single object.
|
||||
- Email and 2FA: you don't need SMTP settings to run it. Two-factor login is optional per user.
|
||||
|
||||
Option: start with demo data instead
|
||||
|
||||
To get the same users, groups and objects the tests use:
|
||||
python manage.py migrate
|
||||
python manage.py loaddata NearBeach_basic_setup.json
|
||||
Then log in as admin with password Test1234$. As I flagged eords, so only do this locally.
|
||||
|
||||
Only if you change the Vue code
|
||||
|
||||
npm install
|
||||
npm run watch # or: npm run prod for a one-off build
|
||||
The build output goes to NearBeach/static/NearBeach/, which up.
|
||||
|
||||
Leave these alone
|
||||
|
||||
- db.sqlite3-bak: the settings point at db.sqlite3, so the bname it to run the app: it holds the eight Test1234$ users and the 2FA key.
|
||||
- local/settings.py: don't commit changes to it. The projectholds the hardcoded SECRET_KEY.
|
||||
|
||||
Do you want me to set it up and start the server for you?
|
||||
===
|
||||
❯ list the steps starting with 'cd' and this time include the option to start w/demo data
|
||||
|
||||
Thought for 9s
|
||||
|
||||
Choose either 4a or 4b at step 4.
|
||||
|
||||
1. Go to the project folder
|
||||
cd /home/eric/workspaces/dataannotation/project-6/NearBeach
|
||||
2. Create and activate a virtual environment
|
||||
python3 -m venv venv
|
||||
source venv/bin/activate
|
||||
3. Install the Python dependencies
|
||||
pip install -r requirements-dev.txt
|
||||
4. Set up the database (choose one)
|
||||
|
||||
4a. Empty database with your own admin user
|
||||
python manage.py migrate
|
||||
python manage.py createsuperuser
|
||||
Your first login automatically creates the permission sets, the admin group and the "No Organisation" record.
|
||||
|
||||
4b. Demo data (the same users, groups and objects the tests use)
|
||||
python manage.py migrate
|
||||
python manage.py loaddata NearBeach_basic_setup.json
|
||||
Log in as admin with password Test1234$. Other accounts include team_leader, team_member, read_only and dark_admin, all with the same password. Only use this locally.
|
||||
5. Start the server
|
||||
python manage.py runserver
|
||||
6. Open the app
|
||||
- App: http://localhost:8000/login (use localhost, because 127.0.0.1 isn't in ALLOWED_HOSTS)
|
||||
- Django admin: http://localhost:8000/admin/
|
||||
7. Optional, only if you change the Vue code
|
||||
npm install
|
||||
npm run watch
|
||||
|
||||
To stop the server press Ctrl+C. Run deactivate to leave the virtual environment. To start fresh, delete db.sqlite3 and repeat from step 4. Don't touch db.sqlite3-bak.
|
||||
Reference in New Issue
Block a user