Skip to content

Commit 9f10d7e

Browse files
committed
chore: restore pre-commit configuration
Restore .pre-commit-config.yaml that was in original PR but missing from current branch. This file provides code quality, security scanning, and formatting validation hooks.
1 parent db8e3e0 commit 9f10d7e

13 files changed

Lines changed: 83 additions & 26 deletions

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ systemd/
5353
# Docker files (not needed in build context)
5454
docker-compose.yml
5555
docker-compose.*.yml
56-
Dockerfile.*
56+
Dockerfile.*

.github/workflows/docker-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,4 @@ jobs:
118118
uses: github/codeql-action/upload-sarif@v3
119119
if: always()
120120
with:
121-
sarif_file: 'trivy-results.sarif'
121+
sarif_file: 'trivy-results.sarif'

.pre-commit-config.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.4.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-added-large-files
9+
- id: check-merge-conflict
10+
- id: debug-statements
11+
- id: check-executables-have-shebangs
12+
13+
- repo: https://github.com/psf/black
14+
rev: 23.7.0
15+
hooks:
16+
- id: black
17+
language_version: python3
18+
args: [--line-length=88]
19+
20+
- repo: https://github.com/pycqa/flake8
21+
rev: 6.0.0
22+
hooks:
23+
- id: flake8
24+
args: [--max-line-length=88, --extend-ignore=E203,W503]
25+
26+
- repo: https://github.com/pycqa/isort
27+
rev: 5.12.0
28+
hooks:
29+
- id: isort
30+
args: [--profile=black]
31+
32+
- repo: https://github.com/Yelp/detect-secrets
33+
rev: v1.4.0
34+
hooks:
35+
- id: detect-secrets
36+
args: ['--baseline', '.secrets.baseline']
37+
exclude: |
38+
(?x)^(
39+
config_template\.json|
40+
\.secrets\.baseline
41+
)$
42+
43+
- repo: https://github.com/pre-commit/mirrors-mypy
44+
rev: v1.4.1
45+
hooks:
46+
- id: mypy
47+
additional_dependencies: [types-requests]
48+
args: [--ignore-missing-imports]
49+
50+
- repo: local
51+
hooks:
52+
- id: reddit-config-check
53+
name: Check Reddit config safety
54+
entry: python -c "import json; config = json.load(open('config.json')) if __import__('os').path.exists('config.json') else {}; exit(1) if not config.get('anonymize_moderators', True) else exit(0)"
55+
language: system
56+
files: config\.json$
57+
pass_filenames: false

CLAUDE.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ sqlite3 modlog.db "SELECT action_id, action_type, moderator, removal_reason, sub
5151
# View actions by subreddit
5252
sqlite3 modlog.db "SELECT action_type, moderator, target_author, removal_reason FROM processed_actions WHERE subreddit = 'usenet' ORDER BY created_at DESC LIMIT 5;"
5353

54-
# Track content lifecycle by target ID
54+
# Track content lifecycle by target ID
5555
sqlite3 modlog.db "SELECT target_id, action_type, moderator, removal_reason, datetime(created_at, 'unixepoch') FROM processed_actions WHERE target_id LIKE '%1mkz4jm%' ORDER BY created_at;"
5656

5757
# Manual cleanup of old entries
@@ -62,7 +62,7 @@ sqlite3 modlog.db "DELETE FROM processed_actions WHERE created_at < date('now',
6262

6363
The application supports multiple configuration methods with the following priority (highest to lowest):
6464
1. **Command line arguments** (highest priority)
65-
2. **Environment variables** (override config file)
65+
2. **Environment variables** (override config file)
6666
3. **JSON config file** (base configuration)
6767

6868
### Environment Variables
@@ -71,7 +71,7 @@ All configuration options can be set via environment variables:
7171

7272
#### Reddit Credentials
7373
- `REDDIT_CLIENT_ID`: Reddit app client ID
74-
- `REDDIT_CLIENT_SECRET`: Reddit app client secret
74+
- `REDDIT_CLIENT_SECRET`: Reddit app client secret
7575
- `REDDIT_USERNAME`: Reddit bot username
7676
- `REDDIT_PASSWORD`: Reddit bot password
7777

@@ -132,7 +132,7 @@ python modlog_wiki_publisher.py --debug --batch-size 25 # CLI takes priority
132132

133133
### Display Options
134134
- `anonymize_moderators`: **REQUIRED** to be `true` for security (default: true)
135-
- `true` (ENFORCED): Shows "AutoModerator", "Reddit", or "HumanModerator"
135+
- `true` (ENFORCED): Shows "AutoModerator", "Reddit", or "HumanModerator"
136136
- `false`: **BLOCKED** - Would expose moderator identities publicly
137137

138138
**SECURITY NOTE**: Setting `anonymize_moderators=false` is permanently disabled to protect moderator privacy. The application will refuse to start if this is attempted.
@@ -143,7 +143,7 @@ The application uses configurable action type variables for flexibility:
143143

144144
#### Default Configuration
145145
- **REMOVAL_ACTIONS**: `removelink`, `removecomment`, `spamlink`, `spamcomment`
146-
- **APPROVAL_ACTIONS**: `approvelink`, `approvecomment`
146+
- **APPROVAL_ACTIONS**: `approvelink`, `approvecomment`
147147
- **REASON_ACTIONS**: `addremovalreason`
148148
- **DEFAULT_WIKI_ACTIONS**: All above combined
149149

@@ -184,7 +184,7 @@ Use `--test` flag to verify configuration and Reddit API connectivity without ma
184184
## Content Link Guidelines
185185

186186
**CRITICAL**: Content links in the modlog should NEVER point to user profiles (`/u/username`). Links should only point to:
187-
- Actual removed posts (`/comments/postid/`)
187+
- Actual removed posts (`/comments/postid/`)
188188
- Actual removed comments (`/comments/postid/_/commentid/`)
189189
- No link at all if no actual content is available
190190

@@ -231,14 +231,14 @@ User profile links are a privacy concern and not useful for modlog purposes.
231231

232232
### Content Linking and Display
233233
- ✅ Content links point to actual Reddit posts/comments, never user profiles for privacy
234-
- ✅ Fixed target authors showing as [deleted] - now displays actual usernames
234+
- ✅ Fixed target authors showing as [deleted] - now displays actual usernames
235235
- ✅ Proper content titles extracted from Reddit API data
236236
- ✅ AutoModerator displays as "AutoModerator" (not anonymized)
237237
- ✅ Configurable anonymization for human moderators
238238

239239
### Data Integrity
240240
- ✅ Pipe character escaping for markdown table compatibility
241-
- ✅ Robust error handling for mixed subreddit scenarios
241+
- ✅ Robust error handling for mixed subreddit scenarios
242242
- ✅ Database schema at version 5 with all required columns
243243
- ✅ Consistent Reddit API field usage (action.details vs action.description)
244244

@@ -266,4 +266,4 @@ User profile links are a privacy concern and not useful for modlog purposes.
266266
- **401 errors**: Check app type is "script" and verify client_id/client_secret
267267
- **Wiki permission denied**: Ensure bot has moderator or wiki contributor access
268268
- **Rate limiting**: Increase `--interval` and/or reduce `--batch-size`
269-
- **Module not found**: Always use `/opt/.venv/redditbot/bin/python` instead of system python
269+
- **Module not found**: Always use `/opt/.venv/redditbot/bin/python` instead of system python

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,4 @@ HEALTHCHECK --interval=5m --timeout=10s --start-period=30s --retries=3 \
142142
CMD python -c "import os, sys; sys.exit(0 if os.path.exists(os.getenv('DATABASE_PATH', '/config/data/modlog.db')) else 1)"
143143

144144
# Use s6-overlay as entrypoint
145-
ENTRYPOINT ["/init"]
145+
ENTRYPOINT ["/init"]

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Automatically publishes Reddit moderation logs to a subreddit wiki page with mod
99
* 🗄️ SQLite database for deduplication and retention with **multi-subreddit support**
1010
* ⏰ Configurable update intervals with continuous daemon mode
1111
* 🔒 Automatic cleanup of old entries with configurable retention
12-
* ⚡ Handles Reddit's 524KB wiki size limit automatically
12+
* ⚡ Handles Reddit's 524KB wiki size limit automatically
1313
* 🧩 Fully CLI-configurable (no need to edit `config.json`)
1414
* 📁 Per-subreddit log files for debugging and monitoring
1515
* 🔒 Configurable moderator anonymization (AutoModerator/HumanModerator)
@@ -162,7 +162,7 @@ Options:
162162
### Force Commands Explained
163163
164164
**--force-modlog**: Complete rebuild from Reddit
165-
- Fetches ALL recent modlog actions from Reddit API
165+
- Fetches ALL recent modlog actions from Reddit API
166166
- Stores them in database
167167
- Rebuilds entire wiki page from database
168168
- Use when: Starting fresh, major updates, or troubleshooting
@@ -181,7 +181,7 @@ Options:
181181
# Complete rebuild from Reddit API
182182
python modlog_wiki_publisher.py --source-subreddit usenet --force-modlog
183183
184-
# Update wiki with current database data (bypass cache)
184+
# Update wiki with current database data (bypass cache)
185185
python modlog_wiki_publisher.py --source-subreddit usenet --force-wiki
186186
187187
# Do both (equivalent to old --force)

config_template.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
"show_full_ids": false,
2121
"id_format": "prefixed"
2222
}
23-
}
23+
}

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@ services:
6161
# - SOURCE_SUBREDDIT=${SOURCE_SUBREDDIT_2}
6262
# volumes:
6363
# - ./data2:/config/data
64-
# - ./logs2:/config/logs
64+
# - ./logs2:/config/logs

renovate.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"labels": ["dependencies"],
99
"assigneesFromCodeOwners": true,
1010
"reviewersFromCodeOwners": true,
11-
11+
1212
"packageRules": [
1313
{
1414
"description": "Python dependencies - group minor and patch updates",
@@ -48,14 +48,14 @@
4848

4949
"prConcurrentLimit": 3,
5050
"prHourlyLimit": 2,
51-
51+
5252
"commitMessageTopic": "{{depName}}",
5353
"commitMessageAction": "update",
5454
"commitMessageExtra": "to {{#if isPinDigest}}{{{newDigestShort}}}{{else}}{{#if isMajor}}{{prettyNewMajor}}{{else}}{{#if isSingleVersion}}{{prettyNewVersion}}{{else}}{{#if newValue}}{{{newValue}}}{{else}}{{{newDigestShort}}}{{/if}}{{/if}}{{/if}}{{/if}}",
55-
55+
5656
"prTitle": "{{#if isPin}}Pin{{else}}Update{{/if}} {{depName}} {{#if isMajor}}(major){{else}}{{#if isMinor}}(minor){{else}}{{#if isPatch}}(patch){{/if}}{{/if}}{{/if}}",
5757
"prBodyTemplate": "{{{header}}}{{{table}}}{{{notes}}}{{{changelogs}}}{{{configDescription}}}{{{controls}}}{{{footer}}}",
58-
58+
5959
"enabledManagers": [
6060
"dockerfile",
6161
"docker-compose",
@@ -72,4 +72,4 @@
7272

7373
"platformAutomerge": false,
7474
"requiredStatusChecks": null
75-
}
75+
}

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
praw>=7.7.0
1+
praw>=7.7.0

0 commit comments

Comments
 (0)