Skip to content

A personal cyber‑security habit tracker with automated daily‑intel reports, CSV validation, pre‑commit hooks, and CI.

License

Notifications You must be signed in to change notification settings

JimBLogic/CyberDailyLog

Repository files navigation

CyberDailyLog

Validate CSV

🎯 Latest Cyber Intelligence

📊 View Latest Report - Updated daily with free certifications & critical CVEs

Store my daily‑log CSV, news‑scan markdown, and automation scripts.

License: MIT


Make It Work

Quick commands to get the repository working on a fresh machine (Windows/PowerShell or WSL/Linux).

Prerequisites

  • Git
  • Python 3.8+ (or 3.x)
  • Optionally pwsh (PowerShell 7) for the preferred hook variant

Quick Start (Windows PowerShell)

Run these from the repo root:

# Create and activate a virtual environment
python -m venv .venv
.\.venv\Scripts\python -m pip install --upgrade pip

# Install test/developer tools
.\.venv\Scripts\python -m pip install pytest

# Install repository hooks (sets local git config core.hooksPath)
./scripts/install-githooks.ps1

# Run unit tests
.\.venv\Scripts\python -m pytest -q

# Run validator (may auto-insert header / normalize dates)
.\.venv\Scripts\python scripts/validate_csv.py

Quick Start (WSL / Git Bash / Linux)

python3 -m venv .venv
. .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install pytest
./scripts/install-githooks.sh
pytest -q
python3 scripts/validate_csv.py

Or use the Makefile:

make install-hooks
make validate-csv

Developer Setup

Install Hooks

After cloning the repository, enable the versioned Git hooks once:

  • Windows (PowerShell):

    ./scripts/install-githooks.ps1
  • WSL / Git Bash / Linux:

    ./scripts/install-githooks.sh
  • Or use the Makefile:

    make install-hooks

The installer sets the local Git config core.hooksPath to .githooks so hooks are enabled only for that clone.

Why Hooks?

  • Hooks are versioned in the repository so pre-commit logic is reviewed and updated alongside code.
  • Local pre-commit checks give quick feedback and prevent malformed rows from entering daily-log.csv.

What the Validator Checks

  • scripts/validate_csv.py validates that every non-empty line in daily-log.csv has exactly 4 comma-separated columns.
  • The pre-commit hook runs the same check locally and will block commits that stage an invalid daily-log.csv.
  • Run locally with:
    make validate-csv
    # or
    python3 scripts/validate_csv.py

PowerShell 7 (pwsh) vs Windows PowerShell

  • The installer prefers pwsh (PowerShell 7). If pwsh is available on PATH the installer will use the pwsh-shebang hook variant; otherwise it installs a Windows PowerShell fallback so hooks still run on typical Windows systems.
  • To install PowerShell 7 on Windows:
    1. Download the latest MSI from: https://github.com/PowerShell/PowerShell/releases/latest
    2. Run the MSI and accept the defaults (it installs to C:\Program Files\PowerShell\7\ by default).
    3. Open a new terminal and verify with:
      pwsh -v
    4. Re-run the installer:
      ./scripts/install-githooks.ps1

Notes on Hooks and Validation

  • Hooks are versioned in .githooks. The installer sets core.hooksPath to .githooks in the local clone, so no global Git state is changed.
  • The hook tries to run the canonical validator scripts/validate_csv.py using python3 (or python) if available. If Python is not found, the hook uses a lightweight PowerShell fallback that enforces the 4-column rule.
  • scripts/validate_csv.py:
    • strips a UTF‑8 BOM if present,
    • auto-inserts the header date,pillar,task,notes when the file is empty or when the first row looks like data,
    • normalizes common date formats into YYYY-MM-DD, and
    • validates each data row for 4 columns, a valid date, and non-empty pillar and task fields.

CI Behavior (GitHub Actions)

  • The workflow .github/workflows/validate-csv.yml runs unit tests (pytest) and then the validator; if the validator reports issues on a PR, the workflow comments on the PR with the validator's output to help contributors fix problems quickly.

Troubleshooting

  • If pytest isn't found on the command line, use the venv Python to run it:

    .\.venv\Scripts\python -m pytest -q
  • If pwsh (PowerShell 7) is not installed, the installer will default to the Windows PowerShell variant so hooks still run on typical Windows systems. To install PowerShell 7 (optional):

  • If you see a BOM-only or empty daily-log.csv causing earlier validator failures, the validator now strips BOMs and will auto-add a header. You can also remove the BOM manually using:

    (Get-Content -Raw -Encoding UTF8 daily-log.csv) -replace '^\uFEFF','' | Set-Content -Encoding UTF8 daily-log.csv

🤝 Contributing

Contributions are welcome! Please see CONTRIBUTING.md for detailed guidelines on:

  • Setting up your development environment
  • Installing Git hooks
  • Running tests and validation
  • CSV format requirements
  • Pull request process

For questions or suggestions, open an issue on GitHub.


📄 License

MIT – see LICENSE for full text.

About

A personal cyber‑security habit tracker with automated daily‑intel reports, CSV validation, pre‑commit hooks, and CI.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published