diff --git a/.github/ISSUE_TEMPLATE/unblock-request.yml b/.github/ISSUE_TEMPLATE/unblock-request.yml index d8e180f..1c5c901 100644 --- a/.github/ISSUE_TEMPLATE/unblock-request.yml +++ b/.github/ISSUE_TEMPLATE/unblock-request.yml @@ -1,5 +1,5 @@ name: Unblock request (blocked by mistake) -description: A legitimate business or service is blocked by a spamwall rule. +description: A legitimate business or service is blocked by a SpamWall rule. labels: [unblock] body: - type: input @@ -18,7 +18,7 @@ body: id: rule attributes: label: Rule ID that blocked it (if shown) - description: SpamBlocker shows it in the call log, for example "spamwall IN-CC-LANDLINE". + description: SpamBlocker shows it in the call log, for example "SpamWall IN-CC-LANDLINE". - type: textarea id: why attributes: diff --git a/CHANGELOG.md b/CHANGELOG.md index f5ff566..a4e6e7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), ## [Unreleased] +## [0.2.0] - 2026-11-27 + +### Added +- Separate import files: `settings.gz` (Others), `rules-default.gz` and `rules-strict.gz` (Regex Settings), and `complete.gz` (both), each with a readable `.json` twin. +- Per-type import files `spamblocker/types/.gz` (one block rule plus the allow rules). +- `docs/IMPORT.md`: which file to pick, step-by-step import, nuances and manual steps. +- `rules/in/patterns.md`, a generated table of every pattern. +- Checks for file header comments, IDs matching file names and shared priorities. + +### Changed +- Display name is now SpamWall in prose, banner and rule descriptions. +- Rule sources split into one file per pattern under `rules/in/allow/`, `block/` and `optional/`. +- README Quick start shortened; added a Files table and a Releases line. +- Removed `spamwall-in*.{gz,json}` (replaced by the files above). + ## [0.1.0] - 2026-11-27 ### Added @@ -13,5 +28,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), - One-click SpamBlocker import files and plain regex lists. - Unblock-request and new-pattern issue templates. -[Unreleased]: https://github.com/wasimness/spamwall/compare/v0.1.0...HEAD +[Unreleased]: https://github.com/wasimness/spamwall/compare/v0.2.0...HEAD +[0.2.0]: https://github.com/wasimness/spamwall/compare/v0.1.0...v0.2.0 [0.1.0]: https://github.com/wasimness/spamwall/releases/tag/v0.1.0 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bb756aa..c22d5c4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,9 +1,9 @@ # Contributing -- Rules live in `rules//`: `allow.txt`, `block.txt`, `optional-block.txt` and `allow-apps.txt`. +- Rules live in `rules//`: one file per pattern in `allow/`, `block/` and `optional/` (named by ID), and `allow-apps.txt`. - One regex per line, matched against the national number (no country code, no leading 0), followed by `# ID | what | source`. - Prefer a range (pattern) over single numbers, but keep it narrow: a block must not catch shopping, delivery, ride, payment, bank or government service calls. -- Never add official service series (India: 1600, 1601) to `block.txt`. +- Never add official service series (India: 1600, 1601) to `block/`. - Never commit personal phone numbers or call logs. - After editing, run `python -I tools/build_spamblocker.py` and commit the rebuilt files in `spamblocker/`. - Fix false positives first. An unblock request outranks a new block. diff --git a/README.md b/README.md index f4229f7..2c3a897 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,47 @@ -# spamwall +# SpamWall -![spamwall: spam call and SMS block patterns for India](assets/banner.svg) +![SpamWall: spam call and SMS block patterns for India](assets/banner.svg) -**For Indian phone numbers (+91), calls and SMS.** spamwall is a set of pattern-based block rules you can import in one click. It is built for [SpamBlocker](https://github.com/aj3423/SpamBlocker) on Android; the plain regex lists work in any blocker that accepts regular expressions. +**For Indian phone numbers (+91), calls and SMS.** SpamWall is a set of pattern-based block rules you can import in one click. It is built for [SpamBlocker](https://github.com/aj3423/SpamBlocker) on Android; the plain regex lists work in any blocker that accepts regular expressions. It blocks whole number ranges used by telemarketers and call centres instead of single numbers. Every rule filters both calls and SMS. Calls and messages from shopping, delivery, ride and payment apps, from your contacts, and from official service lines are never blocked. > SMS filtering works only when **SMS** is switched on under *Settings > Screening* in SpamBlocker; follow the setup prompt it shows. ## The app: SpamBlocker -spamwall's import files are made for **[SpamBlocker](https://github.com/aj3423/SpamBlocker)**, a free, open-source call and SMS blocker for Android by aj3423. It is the app the maintainer uses every day with these rules. +SpamWall's import files are made for **[SpamBlocker](https://github.com/aj3423/SpamBlocker)**, a free, open-source call and SMS blocker for Android by aj3423. It is the app the maintainer uses every day with these rules. - Get it from [F-Droid](https://f-droid.org/packages/spam.blocker/) or the [GitHub releases page](https://github.com/aj3423/SpamBlocker/releases). - It runs on your phone with no account, and number checks happen on the device. - Questions about the app itself go to the [SpamBlocker repository](https://github.com/aj3423/SpamBlocker/issues); questions about these rules go [here](../../issues). -spamwall is a separate community project and is not made by or affiliated with SpamBlocker. +SpamWall is a separate community project and is not made by or affiliated with SpamBlocker. ## Quick start (SpamBlocker) -1. In SpamBlocker, export a backup first: **Settings > Backup > Export**. An import replaces your number rules. -2. Download [`spamblocker/spamwall-in.gz`](spamblocker/spamwall-in.gz) to your phone. -3. **Settings > Backup > Import**, pick the file, keep only **Others** and **Regex Settings** under *Include Settings*, then tap **Import**. -4. **Recent Apps** comes pre-filled with the shopping, delivery, ride, payment and government apps in [`rules/in/allow-apps.txt`](rules/in/allow-apps.txt), set to 120 minutes. If you used one of them in the last 2 hours, any call gets through, so delivery riders and drivers on masked numbers reach you. Apps you have not installed are ignored. Add your own bank and broker apps in **Settings > Recent Apps**. -5. Check that **Contacts**, **Repeated Call**, **Dialed Number** and **Answered Number** are on. +1. Export a backup first (**Settings > Backup > Export**), because an import replaces your number rules. +2. Download [`spamblocker/complete.gz`](spamblocker/complete.gz), then **Settings > Backup > Import** and pick it. +3. Follow the full guide, including the manual steps the import cannot do: [docs/IMPORT.md](docs/IMPORT.md). -Want bank and insurance service calls blocked too? Use `spamwall-in-strict.gz` instead, and add your own banks' 1600 numbers to your contacts first. +## Files + +| File | What it has | +|---|---| +| [`spamblocker/settings.gz`](spamblocker/settings.gz) | Only the Others category (contacts, STIR, repeated call, dialed, answered, Recent Apps) | +| [`spamblocker/rules-default.gz`](spamblocker/rules-default.gz) | Only the Regex Settings category: allow rules and default block rules | +| [`spamblocker/rules-strict.gz`](spamblocker/rules-strict.gz) | `rules-default` plus IN-1600 (bank and government service calls) | +| [`spamblocker/complete.gz`](spamblocker/complete.gz) | `settings` plus `rules-default`, for a one-tap full setup | +| [`spamblocker/types/.gz`](spamblocker/types/) | One block pattern plus the allow rules (Regex Settings only), for blocking just one kind of call | +| [`rules/in/`](rules/in/) | One file per pattern in `allow/`, `block/` and `optional/`, plus [`allow-apps.txt`](rules/in/allow-apps.txt) | +| [`rules/in/patterns.md`](rules/in/patterns.md) | Table of every pattern, generated from the files | + +Each `.gz` has a readable `.json` twin. + +**What can be combined:** `settings` + any ONE rules file (`rules-default`, `rules-strict` or one `types/` file) is fine. Two rules files do not stack: the second replaces the first, and also deletes your own number rules. `complete` already has settings and default rules. + +**Short version of the caveats:** settings never touch number rules; rules never touch settings. Importing `settings.gz` replaces your Recent Apps list and allow switches. Export a backup first, it is your undo. Not tested on every phone and SpamBlocker version, so report problems as issues. Details: [docs/IMPORT.md](docs/IMPORT.md). + +**Releases:** download the files from the [latest release](../../releases/latest). ## How the rules are checked @@ -33,9 +49,9 @@ SpamBlocker checks higher priorities first. Allow and block rules never share a | Priority | Type | Rules | |---|---|---| -| 15 | Allow | `allow.txt` (official delivery series, known support numbers) | +| 15 | Allow | `rules/in/allow/` (official delivery series, known support numbers) | | 10 | Allow | Contacts, repeated calls, numbers you dialled or answered, Recent Apps (built into SpamBlocker) | -| 5 | Block | `block.txt` | +| 5 | Block | `rules/in/block/` | ## India rules @@ -57,7 +73,7 @@ Numbers are matched without `+91` or a leading `0`. | IN-CC-BLR | `^(803710\|...)\d{4}$` | Narrow Bengaluru call-centre blocks. Bengaluru `080` numbers are not blocked as a whole, because delivery apps call from them | Clustered from community spam reports | | IN-BULK-MOBILE | `^(657350\|...)\d{4}$` | Mobile number blocks used for bulk telemarketing | Clustered from community spam reports | -### Optional (strict file only) +### Optional (`rules-strict` only) | ID | Pattern | What it blocks | Why it is off by default | |---|---|---|---| @@ -71,7 +87,7 @@ Open an [**Unblock request**](../../issues/new?template=unblock-request.yml). Gi ## Contributing -See [CONTRIBUTING.md](CONTRIBUTING.md). Edit the `.txt` files in `rules//`, then run `python -I tools/build_spamblocker.py` to rebuild the import files. +See [CONTRIBUTING.md](CONTRIBUTING.md). Edit the files in `rules//allow/`, `block/` and `optional/`, then run `python -I tools/build_spamblocker.py` to rebuild the import files. ## License diff --git a/assets/banner.svg b/assets/banner.svg index 98a4519..017bd2e 100644 --- a/assets/banner.svg +++ b/assets/banner.svg @@ -1,5 +1,5 @@ - spamwall + SpamWall Pattern-based spam call and SMS blocking rules for Indian numbers @@ -10,7 +10,7 @@ ^140\d{7}$^(3366|2250)call centres - spamwall + SpamWall Spam call and SMS block patterns for India (+91) One-click import for SpamBlocker diff --git a/docs/IMPORT.md b/docs/IMPORT.md new file mode 100644 index 0000000..c2c52b7 --- /dev/null +++ b/docs/IMPORT.md @@ -0,0 +1,58 @@ +# Import guide (SpamBlocker) + +> **Read this first** +> +> - Settings and rules import separately. `settings.gz` only touches app settings (allow switches, Recent Apps) and never your number rules. `rules-*.gz` and `types/*.gz` only touch number rules. `complete.gz` does both. +> - Number-rule imports do not stack. Each import replaces ALL number rules, including your own and any earlier SpamWall import. Pick ONE: a single type file (blocks only that kind of call) OR `rules-default.gz` / `rules-strict.gz` (all types). For two or three types, import the all-types file, or import one type file and add the other patterns by hand with "New" in Number Rules, copying the regex from `rules/in/block/.txt`. +> - Importing `settings.gz` replaces your Recent Apps list and the allow switches. +> - Always export a backup first; importing it again is the undo. +> - The maintainer has not tested this on every phone and SpamBlocker version. Report problems as [issues](../../issues). + +## What you need + +SpamBlocker for Android, from [F-Droid](https://f-droid.org/packages/spam.blocker/) or the [GitHub releases](https://github.com/aj3423/SpamBlocker/releases). Download the SpamWall files from the [latest release](../../releases/latest). + +## Which file to pick + +| File | What it has | Pick it when | +|---|---|---| +| `complete.gz` | Settings plus default rules (both categories) | You want a full setup in one tap | +| `settings.gz` | Only the "Others" category: contacts, STIR, repeated call, dialed, answered, Recent Apps (120 min) | You want the settings without touching your number rules | +| `rules-default.gz` | Only the "Regex Settings" category: all allow rules and the default block rules | You want the rules without touching your settings | +| `types/.gz` | One block pattern (IN-140, IN-CC-LANDLINE, IN-CC-BLR, IN-BULK-MOBILE or IN-1600) plus the allow rules (IN-1601, IN-AMAZON). Regex Settings only | You want to block only that kind of call | +| `rules-strict.gz` | Same as `rules-default.gz` plus IN-1600 | You also want bank, insurer and government service calls blocked (add your own bank and broker numbers to contacts first) | + +Each file also has a readable `.json` twin in `spamblocker/`. + +## Step-by-step import + +1. In SpamBlocker, open **Settings > Backup > Export** and save a backup of your current setup first. +2. Download the file you picked to your phone. +3. Open **Settings > Backup > Import** and pick the file. +4. In the **Include Settings** dialog, tap a category to move it between Include and Exclude. Keep only the category the file has (Others for `settings.gz`, Regex Settings for `rules-*.gz` and `types/*.gz`, both for `complete.gz`). +5. Confirm the import. + +## Nuances + +- Import REPLACES the whole section. Number rules are cleared and re-added, so importing a `rules-*.gz` file (or `complete.gz`) deletes your own number rules. Export first, or add your own rules again afterwards. +- A file that lacks a category shows "This setting is missing from the backup file and cannot be restored" for that category. Exclude it, as in step 4. +- Allow and block rules must never share a priority. Here allow is 15, the built-in allow checks are 10 and block is 5. +- Numbers are matched without +91 or a leading 0. +- Recent Apps ignores apps that are not installed. +- If you install a new shopping app, add it in Recent Apps by hand. + +## Manual steps the import cannot do + +- Grant SpamBlocker's permissions when it asks: the call screening role, contacts, and usage access for Recent Apps. +- Turn on SMS screening under **Settings > Screening** if you want it, and follow the app's prompts. +- Add your own bank and broker numbers to contacts (with the strict file). +- Optionally turn off Tellows, which sends unknown numbers to tellows.com. +- On Xiaomi/MIUI, allow autostart and set no battery restriction for SpamBlocker so screening keeps running. + +## Using single patterns in another app + +Each pattern is one file: `rules/in//.txt`, where type is `allow`, `block` or `optional`. Copy the regex from the line (the part before `#`) into any blocker that accepts regular expressions. [`rules/in/patterns.md`](../rules/in/patterns.md) lists every pattern. + +## Undo + +Import the backup you exported in step 1. diff --git a/rules/in/allow-apps.txt b/rules/in/allow-apps.txt index 3ea42e7..354f121 100644 --- a/rules/in/allow-apps.txt +++ b/rules/in/allow-apps.txt @@ -1,4 +1,4 @@ -# spamwall - apps whose recent use should let any call through (SpamBlocker "Recent Apps", 120 min) +# SpamWall - apps whose recent use should let any call through (SpamBlocker "Recent Apps", 120 min) # Shopping / e-commerce / live commerce in.amazon.mShop.android.shopping # Amazon com.flipkart.android # Flipkart diff --git a/rules/in/allow.txt b/rules/in/allow.txt deleted file mode 100644 index d18f646..0000000 --- a/rules/in/allow.txt +++ /dev/null @@ -1,3 +0,0 @@ -# spamwall - India ALLOW patterns (checked before block rules) -^1601\d{6}$ # IN-1601 | Official series for utilities, courier and logistics (deliveries) | TRAI Direction 10-08-2026 -^2263257863$ # IN-AMAZON | Amazon India customer service | public number diff --git a/rules/in/allow/IN-1601.txt b/rules/in/allow/IN-1601.txt new file mode 100644 index 0000000..9c63e02 --- /dev/null +++ b/rules/in/allow/IN-1601.txt @@ -0,0 +1,6 @@ +# SpamWall India ALLOW pattern (national number without +91 or leading 0) +# Allows: official series for service and transactional calls from utilities, courier and logistics (your deliveries). +# Source: TRAI Direction 10 Aug 2026 https://trai.gov.in/sites/default/files/2026-08/Direction_10082026.pdf +# False-positive risk: low. Allowing is the safe side; a spammer using this series would break TRAI rules. +# Format: # id | what | source +^1601\d{6}$ # IN-1601 | Official series for utilities, courier and logistics (deliveries) | TRAI Direction 10-08-2026 diff --git a/rules/in/allow/IN-AMAZON.txt b/rules/in/allow/IN-AMAZON.txt new file mode 100644 index 0000000..a35c3ce --- /dev/null +++ b/rules/in/allow/IN-AMAZON.txt @@ -0,0 +1,6 @@ +# SpamWall India ALLOW pattern (national number without +91 or leading 0) +# Allows: Amazon India customer service. +# Source: public number. +# False-positive risk: low. +# Format: # id | what | source +^2263257863$ # IN-AMAZON | Amazon India customer service | public number diff --git a/rules/in/block.txt b/rules/in/block.txt deleted file mode 100644 index ecf66a1..0000000 --- a/rules/in/block.txt +++ /dev/null @@ -1,6 +0,0 @@ -# spamwall - India BLOCK patterns (regex, national number without +91 or leading 0) -# Format: # id | what | source -^140\d{7}$ # IN-140 | Promotional / telemarketing series | TRAI TCCCPR 2018; RBI circular 2025-01 (140 = promotional only) -^(1725|2250|2269|3366|3368|3371|4071|7935|7969|7971)\d{6}$ # IN-CC-LANDLINE | Call-centre landline ranges (Chandigarh, Mumbai, Kolkata, Hyderabad, Ahmedabad) | clustered from community spam reports -^(803710|803720|804795|804819|806935|806954|806985)\d{4}$ # IN-CC-BLR | Bengaluru call-centre blocks | clustered from community spam reports -^(657350|731361|914714|922807|942209|948470)\d{4}$ # IN-BULK-MOBILE | Bulk telemarketing mobile ranges | clustered from community spam reports diff --git a/rules/in/block/IN-140.txt b/rules/in/block/IN-140.txt new file mode 100644 index 0000000..f5008b2 --- /dev/null +++ b/rules/in/block/IN-140.txt @@ -0,0 +1,6 @@ +# SpamWall India BLOCK pattern (national number without +91 or leading 0) +# Blocks: promotional and telemarketing calls and SMS from the 140 series. +# Source: TRAI TCCCPR 2018 https://trai.gov.in/release-publication/directions ; RBI circular Jan 2025 https://www.rbi.org.in/scripts/NotificationUser.aspx?Id=12770 +# False-positive risk: low. The series is for promotions only. +# Format: # id | what | source +^140\d{7}$ # IN-140 | Promotional / telemarketing series | TRAI TCCCPR 2018; RBI circular 2025-01 (140 = promotional only) diff --git a/rules/in/block/IN-BULK-MOBILE.txt b/rules/in/block/IN-BULK-MOBILE.txt new file mode 100644 index 0000000..2e69a40 --- /dev/null +++ b/rules/in/block/IN-BULK-MOBILE.txt @@ -0,0 +1,6 @@ +# SpamWall India BLOCK pattern (national number without +91 or leading 0) +# Blocks: mobile number blocks used for bulk telemarketing. +# Source: clustered from community spam reports. +# False-positive risk: medium. Mobile blocks can be reassigned to ordinary users. +# Format: # id | what | source +^(657350|731361|914714|922807|942209|948470)\d{4}$ # IN-BULK-MOBILE | Bulk telemarketing mobile ranges | clustered from community spam reports diff --git a/rules/in/block/IN-CC-BLR.txt b/rules/in/block/IN-CC-BLR.txt new file mode 100644 index 0000000..aecd51f --- /dev/null +++ b/rules/in/block/IN-CC-BLR.txt @@ -0,0 +1,6 @@ +# SpamWall India BLOCK pattern (national number without +91 or leading 0) +# Blocks: narrow Bengaluru call-centre blocks (not all of 080). +# Source: clustered from community spam reports. +# False-positive risk: medium. Delivery apps call from other 080 numbers, which are not blocked. +# Format: # id | what | source +^(803710|803720|804795|804819|806935|806954|806985)\d{4}$ # IN-CC-BLR | Bengaluru call-centre blocks | clustered from community spam reports diff --git a/rules/in/block/IN-CC-LANDLINE.txt b/rules/in/block/IN-CC-LANDLINE.txt new file mode 100644 index 0000000..2d47d3f --- /dev/null +++ b/rules/in/block/IN-CC-LANDLINE.txt @@ -0,0 +1,6 @@ +# SpamWall India BLOCK pattern (national number without +91 or leading 0) +# Blocks: call-centre landline ranges in Chandigarh, Mumbai, Kolkata, Hyderabad and Ahmedabad. +# Source: clustered from community spam reports. +# False-positive risk: medium. Ranges are narrow but a real business in them would be blocked; use an unblock request. +# Format: # id | what | source +^(1725|2250|2269|3366|3368|3371|4071|7935|7969|7971)\d{6}$ # IN-CC-LANDLINE | Call-centre landline ranges (Chandigarh, Mumbai, Kolkata, Hyderabad, Ahmedabad) | clustered from community spam reports diff --git a/rules/in/optional-block.txt b/rules/in/optional-block.txt deleted file mode 100644 index eb41d0f..0000000 --- a/rules/in/optional-block.txt +++ /dev/null @@ -1,2 +0,0 @@ -# spamwall - India OPTIONAL block patterns (off by default) -^1600\d{6}$ # IN-1600 | Official BFSI + Government service/transactional series. Blocks REAL bank, insurer, broker and govt calls too. Enable only if you add your own banks to allow.txt | TRAI Direction (PIB PRID 2191647) diff --git a/rules/in/optional/IN-1600.txt b/rules/in/optional/IN-1600.txt new file mode 100644 index 0000000..0481d45 --- /dev/null +++ b/rules/in/optional/IN-1600.txt @@ -0,0 +1,6 @@ +# SpamWall India OPTIONAL BLOCK pattern (off by default; only in rules-strict) +# Blocks: official BFSI and government service and transactional series. +# Source: TRAI Direction, PIB https://pib.gov.in/PressReleasePage.aspx?PRID=2191647 +# False-positive risk: high. Blocks real bank, insurer, broker and government calls. Add your own banks to contacts first. +# Format: # id | what | source +^1600\d{6}$ # IN-1600 | Official BFSI + Government service/transactional series. Blocks REAL bank, insurer, broker and govt calls too. Enable only if you add your own banks to allow.txt | TRAI Direction (PIB PRID 2191647) diff --git a/rules/in/patterns.md b/rules/in/patterns.md new file mode 100644 index 0000000..b258caf --- /dev/null +++ b/rules/in/patterns.md @@ -0,0 +1,12 @@ + +# IN patterns + +| ID | Type | Regex | What | Source | Priority | +|---|---|---|---|---|---| +| IN-1601 | allow | `^1601\d{6}$` | Official series for utilities, courier and logistics (deliveries) | TRAI Direction 10-08-2026 | 15 | +| IN-AMAZON | allow | `^2263257863$` | Amazon India customer service | public number | 15 | +| IN-140 | block | `^140\d{7}$` | Promotional / telemarketing series | TRAI TCCCPR 2018; RBI circular 2025-01 (140 = promotional only) | 5 | +| IN-BULK-MOBILE | block | `^(657350\|731361\|914714\|922807\|942209\|948470)\d{4}$` | Bulk telemarketing mobile ranges | clustered from community spam reports | 5 | +| IN-CC-BLR | block | `^(803710\|803720\|804795\|804819\|806935\|806954\|806985)\d{4}$` | Bengaluru call-centre blocks | clustered from community spam reports | 5 | +| IN-CC-LANDLINE | block | `^(1725\|2250\|2269\|3366\|3368\|3371\|4071\|7935\|7969\|7971)\d{6}$` | Call-centre landline ranges (Chandigarh, Mumbai, Kolkata, Hyderabad, Ahmedabad) | clustered from community spam reports | 5 | +| IN-1600 | optional | `^1600\d{6}$` | Official BFSI + Government service/transactional series. Blocks REAL bank, insurer, broker and govt calls too. Enable only if you add your own banks to allow.txt | TRAI Direction (PIB PRID 2191647) | 5 | diff --git a/spamblocker/complete.gz b/spamblocker/complete.gz new file mode 100644 index 0000000..6db9c6f Binary files /dev/null and b/spamblocker/complete.gz differ diff --git a/spamblocker/spamwall-in.json b/spamblocker/complete.json similarity index 91% rename from spamblocker/spamwall-in.json rename to spamblocker/complete.json index 1666512..00c7f7d 100644 --- a/spamblocker/spamwall-in.json +++ b/spamblocker/complete.json @@ -108,7 +108,7 @@ "patternExtra": "", "patternExtraFlags": 0, "patternExtraModeType": 0, - "description": "spamwall IN-1601: Official series for utilities, courier and logistics (deliveries)", + "description": "SpamWall IN-1601: Official series for utilities, courier and logistics (deliveries)", "priority": 15, "isBlacklist": false, "flags": 3, @@ -125,7 +125,7 @@ "patternExtra": "", "patternExtraFlags": 0, "patternExtraModeType": 0, - "description": "spamwall IN-AMAZON: Amazon India customer service", + "description": "SpamWall IN-AMAZON: Amazon India customer service", "priority": 15, "isBlacklist": false, "flags": 3, @@ -142,7 +142,7 @@ "patternExtra": "", "patternExtraFlags": 0, "patternExtraModeType": 0, - "description": "spamwall IN-140: Promotional / telemarketing series", + "description": "SpamWall IN-140: Promotional / telemarketing series", "priority": 5, "isBlacklist": true, "flags": 3, @@ -153,13 +153,13 @@ }, { "id": 201, - "pattern": "^(1725|2250|2269|3366|3368|3371|4071|7935|7969|7971)\\d{6}$", + "pattern": "^(657350|731361|914714|922807|942209|948470)\\d{4}$", "patternFlags": 8192, "patternModeType": 0, "patternExtra": "", "patternExtraFlags": 0, "patternExtraModeType": 0, - "description": "spamwall IN-CC-LANDLINE: Call-centre landline ranges (Chandigarh, Mumbai, Kolkata, Hyderabad, Ahmedabad)", + "description": "SpamWall IN-BULK-MOBILE: Bulk telemarketing mobile ranges", "priority": 5, "isBlacklist": true, "flags": 3, @@ -176,7 +176,7 @@ "patternExtra": "", "patternExtraFlags": 0, "patternExtraModeType": 0, - "description": "spamwall IN-CC-BLR: Bengaluru call-centre blocks", + "description": "SpamWall IN-CC-BLR: Bengaluru call-centre blocks", "priority": 5, "isBlacklist": true, "flags": 3, @@ -187,13 +187,13 @@ }, { "id": 203, - "pattern": "^(657350|731361|914714|922807|942209|948470)\\d{4}$", + "pattern": "^(1725|2250|2269|3366|3368|3371|4071|7935|7969|7971)\\d{6}$", "patternFlags": 8192, "patternModeType": 0, "patternExtra": "", "patternExtraFlags": 0, "patternExtraModeType": 0, - "description": "spamwall IN-BULK-MOBILE: Bulk telemarketing mobile ranges", + "description": "SpamWall IN-CC-LANDLINE: Call-centre landline ranges (Chandigarh, Mumbai, Kolkata, Hyderabad, Ahmedabad)", "priority": 5, "isBlacklist": true, "flags": 3, diff --git a/spamblocker/rules-default.gz b/spamblocker/rules-default.gz new file mode 100644 index 0000000..4e38616 Binary files /dev/null and b/spamblocker/rules-default.gz differ diff --git a/spamblocker/rules-default.json b/spamblocker/rules-default.json new file mode 100644 index 0000000..6b55cc2 --- /dev/null +++ b/spamblocker/rules-default.json @@ -0,0 +1,113 @@ +{ + "categories": { + "all": [ + "REGEX_RULES" + ] + }, + "numberRules": { + "rules": [ + { + "id": 100, + "pattern": "^1601\\d{6}$", + "patternFlags": 8192, + "patternModeType": 0, + "patternExtra": "", + "patternExtraFlags": 0, + "patternExtraModeType": 0, + "description": "SpamWall IN-1601: Official series for utilities, courier and logistics (deliveries)", + "priority": 15, + "isBlacklist": false, + "flags": 3, + "channel": "Low", + "schedule": "", + "blockType": 0, + "blockTypeConfig": "" + }, + { + "id": 101, + "pattern": "^2263257863$", + "patternFlags": 8192, + "patternModeType": 0, + "patternExtra": "", + "patternExtraFlags": 0, + "patternExtraModeType": 0, + "description": "SpamWall IN-AMAZON: Amazon India customer service", + "priority": 15, + "isBlacklist": false, + "flags": 3, + "channel": "Low", + "schedule": "", + "blockType": 0, + "blockTypeConfig": "" + }, + { + "id": 200, + "pattern": "^140\\d{7}$", + "patternFlags": 8192, + "patternModeType": 0, + "patternExtra": "", + "patternExtraFlags": 0, + "patternExtraModeType": 0, + "description": "SpamWall IN-140: Promotional / telemarketing series", + "priority": 5, + "isBlacklist": true, + "flags": 3, + "channel": "Low", + "schedule": "", + "blockType": 0, + "blockTypeConfig": "" + }, + { + "id": 201, + "pattern": "^(657350|731361|914714|922807|942209|948470)\\d{4}$", + "patternFlags": 8192, + "patternModeType": 0, + "patternExtra": "", + "patternExtraFlags": 0, + "patternExtraModeType": 0, + "description": "SpamWall IN-BULK-MOBILE: Bulk telemarketing mobile ranges", + "priority": 5, + "isBlacklist": true, + "flags": 3, + "channel": "Low", + "schedule": "", + "blockType": 0, + "blockTypeConfig": "" + }, + { + "id": 202, + "pattern": "^(803710|803720|804795|804819|806935|806954|806985)\\d{4}$", + "patternFlags": 8192, + "patternModeType": 0, + "patternExtra": "", + "patternExtraFlags": 0, + "patternExtraModeType": 0, + "description": "SpamWall IN-CC-BLR: Bengaluru call-centre blocks", + "priority": 5, + "isBlacklist": true, + "flags": 3, + "channel": "Low", + "schedule": "", + "blockType": 0, + "blockTypeConfig": "" + }, + { + "id": 203, + "pattern": "^(1725|2250|2269|3366|3368|3371|4071|7935|7969|7971)\\d{6}$", + "patternFlags": 8192, + "patternModeType": 0, + "patternExtra": "", + "patternExtraFlags": 0, + "patternExtraModeType": 0, + "description": "SpamWall IN-CC-LANDLINE: Call-centre landline ranges (Chandigarh, Mumbai, Kolkata, Hyderabad, Ahmedabad)", + "priority": 5, + "isBlacklist": true, + "flags": 3, + "channel": "Low", + "schedule": "", + "blockType": 0, + "blockTypeConfig": "" + } + ] + } +} \ No newline at end of file diff --git a/spamblocker/rules-strict.gz b/spamblocker/rules-strict.gz new file mode 100644 index 0000000..d5033a7 Binary files /dev/null and b/spamblocker/rules-strict.gz differ diff --git a/spamblocker/spamwall-in-strict.json b/spamblocker/rules-strict.json similarity index 59% rename from spamblocker/spamwall-in-strict.json rename to spamblocker/rules-strict.json index fdc4f0b..d9556dc 100644 --- a/spamblocker/spamwall-in-strict.json +++ b/spamblocker/rules-strict.json @@ -1,103 +1,9 @@ { "categories": { "all": [ - "OTHERS", "REGEX_RULES" ] }, - "contacts": { - "enabled": true, - "isExcusive": false, - "permissivePriority": 10, - "strictPriority": 0 - }, - "stir": { - "enabled": true, - "includeUnverified": false, - "strictPriority": 0 - }, - "repeatedCall": { - "enabled": true, - "times": 1, - "inXMin": 5 - }, - "dialed": { - "enabled": true, - "smsEnabled": true, - "always": false, - "inXDay": 7 - }, - "answered": { - "warningAcknowledged": true, - "enabled": true, - "minDuration": 15, - "inXDay": 7 - }, - "recentApps": { - "list": [ - { - "pkgName": "in.amazon.mShop.android.shopping" - }, - { - "pkgName": "com.flipkart.android" - }, - { - "pkgName": "com.myntra.android" - }, - { - "pkgName": "com.meesho.supply" - }, - { - "pkgName": "com.jio.jiomart" - }, - { - "pkgName": "in.swiggy.android" - }, - { - "pkgName": "com.application.zomato" - }, - { - "pkgName": "com.grofers.customerapp" - }, - { - "pkgName": "com.zeptoconsumerapp" - }, - { - "pkgName": "com.bigbasket.mobileapp" - }, - { - "pkgName": "com.ubercab" - }, - { - "pkgName": "com.rapido.passenger" - }, - { - "pkgName": "com.olacabs.customer" - }, - { - "pkgName": "com.phonepe.app" - }, - { - "pkgName": "net.one97.paytm" - }, - { - "pkgName": "com.google.android.apps.nbu.paisa.user" - }, - { - "pkgName": "com.jio.myjio" - }, - { - "pkgName": "com.paypal.android.p2pmobile" - }, - { - "pkgName": "com.transferwise.android" - }, - { - "pkgName": "in.gov.umang.negd.g2c" - } - ], - "inXMin": 120 - }, "numberRules": { "rules": [ { @@ -108,7 +14,7 @@ "patternExtra": "", "patternExtraFlags": 0, "patternExtraModeType": 0, - "description": "spamwall IN-1601: Official series for utilities, courier and logistics (deliveries)", + "description": "SpamWall IN-1601: Official series for utilities, courier and logistics (deliveries)", "priority": 15, "isBlacklist": false, "flags": 3, @@ -125,7 +31,7 @@ "patternExtra": "", "patternExtraFlags": 0, "patternExtraModeType": 0, - "description": "spamwall IN-AMAZON: Amazon India customer service", + "description": "SpamWall IN-AMAZON: Amazon India customer service", "priority": 15, "isBlacklist": false, "flags": 3, @@ -142,7 +48,7 @@ "patternExtra": "", "patternExtraFlags": 0, "patternExtraModeType": 0, - "description": "spamwall IN-140: Promotional / telemarketing series", + "description": "SpamWall IN-140: Promotional / telemarketing series", "priority": 5, "isBlacklist": true, "flags": 3, @@ -153,13 +59,13 @@ }, { "id": 201, - "pattern": "^(1725|2250|2269|3366|3368|3371|4071|7935|7969|7971)\\d{6}$", + "pattern": "^(657350|731361|914714|922807|942209|948470)\\d{4}$", "patternFlags": 8192, "patternModeType": 0, "patternExtra": "", "patternExtraFlags": 0, "patternExtraModeType": 0, - "description": "spamwall IN-CC-LANDLINE: Call-centre landline ranges (Chandigarh, Mumbai, Kolkata, Hyderabad, Ahmedabad)", + "description": "SpamWall IN-BULK-MOBILE: Bulk telemarketing mobile ranges", "priority": 5, "isBlacklist": true, "flags": 3, @@ -176,7 +82,7 @@ "patternExtra": "", "patternExtraFlags": 0, "patternExtraModeType": 0, - "description": "spamwall IN-CC-BLR: Bengaluru call-centre blocks", + "description": "SpamWall IN-CC-BLR: Bengaluru call-centre blocks", "priority": 5, "isBlacklist": true, "flags": 3, @@ -187,13 +93,13 @@ }, { "id": 203, - "pattern": "^(657350|731361|914714|922807|942209|948470)\\d{4}$", + "pattern": "^(1725|2250|2269|3366|3368|3371|4071|7935|7969|7971)\\d{6}$", "patternFlags": 8192, "patternModeType": 0, "patternExtra": "", "patternExtraFlags": 0, "patternExtraModeType": 0, - "description": "spamwall IN-BULK-MOBILE: Bulk telemarketing mobile ranges", + "description": "SpamWall IN-CC-LANDLINE: Call-centre landline ranges (Chandigarh, Mumbai, Kolkata, Hyderabad, Ahmedabad)", "priority": 5, "isBlacklist": true, "flags": 3, @@ -210,7 +116,7 @@ "patternExtra": "", "patternExtraFlags": 0, "patternExtraModeType": 0, - "description": "spamwall IN-1600: Official BFSI + Government service/transactional series. Blocks REAL bank, insurer, broker and govt ca", + "description": "SpamWall IN-1600: Official BFSI + Government service/transactional series. Blocks REAL bank, insurer, broker and govt ca", "priority": 5, "isBlacklist": true, "flags": 3, diff --git a/spamblocker/settings.gz b/spamblocker/settings.gz new file mode 100644 index 0000000..893c703 Binary files /dev/null and b/spamblocker/settings.gz differ diff --git a/spamblocker/settings.json b/spamblocker/settings.json new file mode 100644 index 0000000..0ebcdaf --- /dev/null +++ b/spamblocker/settings.json @@ -0,0 +1,100 @@ +{ + "categories": { + "all": [ + "OTHERS" + ] + }, + "contacts": { + "enabled": true, + "isExcusive": false, + "permissivePriority": 10, + "strictPriority": 0 + }, + "stir": { + "enabled": true, + "includeUnverified": false, + "strictPriority": 0 + }, + "repeatedCall": { + "enabled": true, + "times": 1, + "inXMin": 5 + }, + "dialed": { + "enabled": true, + "smsEnabled": true, + "always": false, + "inXDay": 7 + }, + "answered": { + "warningAcknowledged": true, + "enabled": true, + "minDuration": 15, + "inXDay": 7 + }, + "recentApps": { + "list": [ + { + "pkgName": "in.amazon.mShop.android.shopping" + }, + { + "pkgName": "com.flipkart.android" + }, + { + "pkgName": "com.myntra.android" + }, + { + "pkgName": "com.meesho.supply" + }, + { + "pkgName": "com.jio.jiomart" + }, + { + "pkgName": "in.swiggy.android" + }, + { + "pkgName": "com.application.zomato" + }, + { + "pkgName": "com.grofers.customerapp" + }, + { + "pkgName": "com.zeptoconsumerapp" + }, + { + "pkgName": "com.bigbasket.mobileapp" + }, + { + "pkgName": "com.ubercab" + }, + { + "pkgName": "com.rapido.passenger" + }, + { + "pkgName": "com.olacabs.customer" + }, + { + "pkgName": "com.phonepe.app" + }, + { + "pkgName": "net.one97.paytm" + }, + { + "pkgName": "com.google.android.apps.nbu.paisa.user" + }, + { + "pkgName": "com.jio.myjio" + }, + { + "pkgName": "com.paypal.android.p2pmobile" + }, + { + "pkgName": "com.transferwise.android" + }, + { + "pkgName": "in.gov.umang.negd.g2c" + } + ], + "inXMin": 120 + } +} \ No newline at end of file diff --git a/spamblocker/spamwall-in-strict.gz b/spamblocker/spamwall-in-strict.gz deleted file mode 100644 index 616038a..0000000 Binary files a/spamblocker/spamwall-in-strict.gz and /dev/null differ diff --git a/spamblocker/spamwall-in.gz b/spamblocker/spamwall-in.gz deleted file mode 100644 index a60db8c..0000000 Binary files a/spamblocker/spamwall-in.gz and /dev/null differ diff --git a/spamblocker/types/IN-140.gz b/spamblocker/types/IN-140.gz new file mode 100644 index 0000000..0c7a3a7 Binary files /dev/null and b/spamblocker/types/IN-140.gz differ diff --git a/spamblocker/types/IN-140.json b/spamblocker/types/IN-140.json new file mode 100644 index 0000000..db0bffc --- /dev/null +++ b/spamblocker/types/IN-140.json @@ -0,0 +1,62 @@ +{ + "categories": { + "all": [ + "REGEX_RULES" + ] + }, + "numberRules": { + "rules": [ + { + "id": 100, + "pattern": "^1601\\d{6}$", + "patternFlags": 8192, + "patternModeType": 0, + "patternExtra": "", + "patternExtraFlags": 0, + "patternExtraModeType": 0, + "description": "SpamWall IN-1601: Official series for utilities, courier and logistics (deliveries)", + "priority": 15, + "isBlacklist": false, + "flags": 3, + "channel": "Low", + "schedule": "", + "blockType": 0, + "blockTypeConfig": "" + }, + { + "id": 101, + "pattern": "^2263257863$", + "patternFlags": 8192, + "patternModeType": 0, + "patternExtra": "", + "patternExtraFlags": 0, + "patternExtraModeType": 0, + "description": "SpamWall IN-AMAZON: Amazon India customer service", + "priority": 15, + "isBlacklist": false, + "flags": 3, + "channel": "Low", + "schedule": "", + "blockType": 0, + "blockTypeConfig": "" + }, + { + "id": 200, + "pattern": "^140\\d{7}$", + "patternFlags": 8192, + "patternModeType": 0, + "patternExtra": "", + "patternExtraFlags": 0, + "patternExtraModeType": 0, + "description": "SpamWall IN-140: Promotional / telemarketing series", + "priority": 5, + "isBlacklist": true, + "flags": 3, + "channel": "Low", + "schedule": "", + "blockType": 0, + "blockTypeConfig": "" + } + ] + } +} \ No newline at end of file diff --git a/spamblocker/types/IN-1600.gz b/spamblocker/types/IN-1600.gz new file mode 100644 index 0000000..2bf7856 Binary files /dev/null and b/spamblocker/types/IN-1600.gz differ diff --git a/spamblocker/types/IN-1600.json b/spamblocker/types/IN-1600.json new file mode 100644 index 0000000..9cd3557 --- /dev/null +++ b/spamblocker/types/IN-1600.json @@ -0,0 +1,62 @@ +{ + "categories": { + "all": [ + "REGEX_RULES" + ] + }, + "numberRules": { + "rules": [ + { + "id": 100, + "pattern": "^1601\\d{6}$", + "patternFlags": 8192, + "patternModeType": 0, + "patternExtra": "", + "patternExtraFlags": 0, + "patternExtraModeType": 0, + "description": "SpamWall IN-1601: Official series for utilities, courier and logistics (deliveries)", + "priority": 15, + "isBlacklist": false, + "flags": 3, + "channel": "Low", + "schedule": "", + "blockType": 0, + "blockTypeConfig": "" + }, + { + "id": 101, + "pattern": "^2263257863$", + "patternFlags": 8192, + "patternModeType": 0, + "patternExtra": "", + "patternExtraFlags": 0, + "patternExtraModeType": 0, + "description": "SpamWall IN-AMAZON: Amazon India customer service", + "priority": 15, + "isBlacklist": false, + "flags": 3, + "channel": "Low", + "schedule": "", + "blockType": 0, + "blockTypeConfig": "" + }, + { + "id": 200, + "pattern": "^1600\\d{6}$", + "patternFlags": 8192, + "patternModeType": 0, + "patternExtra": "", + "patternExtraFlags": 0, + "patternExtraModeType": 0, + "description": "SpamWall IN-1600: Official BFSI + Government service/transactional series. Blocks REAL bank, insurer, broker and govt ca", + "priority": 5, + "isBlacklist": true, + "flags": 3, + "channel": "Low", + "schedule": "", + "blockType": 0, + "blockTypeConfig": "" + } + ] + } +} \ No newline at end of file diff --git a/spamblocker/types/IN-BULK-MOBILE.gz b/spamblocker/types/IN-BULK-MOBILE.gz new file mode 100644 index 0000000..60e7399 Binary files /dev/null and b/spamblocker/types/IN-BULK-MOBILE.gz differ diff --git a/spamblocker/types/IN-BULK-MOBILE.json b/spamblocker/types/IN-BULK-MOBILE.json new file mode 100644 index 0000000..d4ba8a1 --- /dev/null +++ b/spamblocker/types/IN-BULK-MOBILE.json @@ -0,0 +1,62 @@ +{ + "categories": { + "all": [ + "REGEX_RULES" + ] + }, + "numberRules": { + "rules": [ + { + "id": 100, + "pattern": "^1601\\d{6}$", + "patternFlags": 8192, + "patternModeType": 0, + "patternExtra": "", + "patternExtraFlags": 0, + "patternExtraModeType": 0, + "description": "SpamWall IN-1601: Official series for utilities, courier and logistics (deliveries)", + "priority": 15, + "isBlacklist": false, + "flags": 3, + "channel": "Low", + "schedule": "", + "blockType": 0, + "blockTypeConfig": "" + }, + { + "id": 101, + "pattern": "^2263257863$", + "patternFlags": 8192, + "patternModeType": 0, + "patternExtra": "", + "patternExtraFlags": 0, + "patternExtraModeType": 0, + "description": "SpamWall IN-AMAZON: Amazon India customer service", + "priority": 15, + "isBlacklist": false, + "flags": 3, + "channel": "Low", + "schedule": "", + "blockType": 0, + "blockTypeConfig": "" + }, + { + "id": 200, + "pattern": "^(657350|731361|914714|922807|942209|948470)\\d{4}$", + "patternFlags": 8192, + "patternModeType": 0, + "patternExtra": "", + "patternExtraFlags": 0, + "patternExtraModeType": 0, + "description": "SpamWall IN-BULK-MOBILE: Bulk telemarketing mobile ranges", + "priority": 5, + "isBlacklist": true, + "flags": 3, + "channel": "Low", + "schedule": "", + "blockType": 0, + "blockTypeConfig": "" + } + ] + } +} \ No newline at end of file diff --git a/spamblocker/types/IN-CC-BLR.gz b/spamblocker/types/IN-CC-BLR.gz new file mode 100644 index 0000000..6c0c30c Binary files /dev/null and b/spamblocker/types/IN-CC-BLR.gz differ diff --git a/spamblocker/types/IN-CC-BLR.json b/spamblocker/types/IN-CC-BLR.json new file mode 100644 index 0000000..511a533 --- /dev/null +++ b/spamblocker/types/IN-CC-BLR.json @@ -0,0 +1,62 @@ +{ + "categories": { + "all": [ + "REGEX_RULES" + ] + }, + "numberRules": { + "rules": [ + { + "id": 100, + "pattern": "^1601\\d{6}$", + "patternFlags": 8192, + "patternModeType": 0, + "patternExtra": "", + "patternExtraFlags": 0, + "patternExtraModeType": 0, + "description": "SpamWall IN-1601: Official series for utilities, courier and logistics (deliveries)", + "priority": 15, + "isBlacklist": false, + "flags": 3, + "channel": "Low", + "schedule": "", + "blockType": 0, + "blockTypeConfig": "" + }, + { + "id": 101, + "pattern": "^2263257863$", + "patternFlags": 8192, + "patternModeType": 0, + "patternExtra": "", + "patternExtraFlags": 0, + "patternExtraModeType": 0, + "description": "SpamWall IN-AMAZON: Amazon India customer service", + "priority": 15, + "isBlacklist": false, + "flags": 3, + "channel": "Low", + "schedule": "", + "blockType": 0, + "blockTypeConfig": "" + }, + { + "id": 200, + "pattern": "^(803710|803720|804795|804819|806935|806954|806985)\\d{4}$", + "patternFlags": 8192, + "patternModeType": 0, + "patternExtra": "", + "patternExtraFlags": 0, + "patternExtraModeType": 0, + "description": "SpamWall IN-CC-BLR: Bengaluru call-centre blocks", + "priority": 5, + "isBlacklist": true, + "flags": 3, + "channel": "Low", + "schedule": "", + "blockType": 0, + "blockTypeConfig": "" + } + ] + } +} \ No newline at end of file diff --git a/spamblocker/types/IN-CC-LANDLINE.gz b/spamblocker/types/IN-CC-LANDLINE.gz new file mode 100644 index 0000000..f83e9fa Binary files /dev/null and b/spamblocker/types/IN-CC-LANDLINE.gz differ diff --git a/spamblocker/types/IN-CC-LANDLINE.json b/spamblocker/types/IN-CC-LANDLINE.json new file mode 100644 index 0000000..45dd12e --- /dev/null +++ b/spamblocker/types/IN-CC-LANDLINE.json @@ -0,0 +1,62 @@ +{ + "categories": { + "all": [ + "REGEX_RULES" + ] + }, + "numberRules": { + "rules": [ + { + "id": 100, + "pattern": "^1601\\d{6}$", + "patternFlags": 8192, + "patternModeType": 0, + "patternExtra": "", + "patternExtraFlags": 0, + "patternExtraModeType": 0, + "description": "SpamWall IN-1601: Official series for utilities, courier and logistics (deliveries)", + "priority": 15, + "isBlacklist": false, + "flags": 3, + "channel": "Low", + "schedule": "", + "blockType": 0, + "blockTypeConfig": "" + }, + { + "id": 101, + "pattern": "^2263257863$", + "patternFlags": 8192, + "patternModeType": 0, + "patternExtra": "", + "patternExtraFlags": 0, + "patternExtraModeType": 0, + "description": "SpamWall IN-AMAZON: Amazon India customer service", + "priority": 15, + "isBlacklist": false, + "flags": 3, + "channel": "Low", + "schedule": "", + "blockType": 0, + "blockTypeConfig": "" + }, + { + "id": 200, + "pattern": "^(1725|2250|2269|3366|3368|3371|4071|7935|7969|7971)\\d{6}$", + "patternFlags": 8192, + "patternModeType": 0, + "patternExtra": "", + "patternExtraFlags": 0, + "patternExtraModeType": 0, + "description": "SpamWall IN-CC-LANDLINE: Call-centre landline ranges (Chandigarh, Mumbai, Kolkata, Hyderabad, Ahmedabad)", + "priority": 5, + "isBlacklist": true, + "flags": 3, + "channel": "Low", + "schedule": "", + "blockType": 0, + "blockTypeConfig": "" + } + ] + } +} \ No newline at end of file diff --git a/tools/build_spamblocker.py b/tools/build_spamblocker.py index e510d46..cb17aca 100644 --- a/tools/build_spamblocker.py +++ b/tools/build_spamblocker.py @@ -1,8 +1,8 @@ -"""Build the SpamBlocker one-click import files from rules//*.txt. +"""Build the SpamBlocker import files from rules// and write patterns.md. Usage: python -I tools/build_spamblocker.py -Writes spamblocker/spamwall-.json, spamwall-.gz (default) and -spamwall--strict.gz (also blocks the optional list). +Writes spamblocker/{settings,rules-default,rules-strict,complete}.{gz,json} +and rules//patterns.md. Old spamwall-*.{gz,json} files are removed. """ import gzip import json @@ -27,7 +27,18 @@ def read_rules(path): continue pattern, _, note = line.partition("#") parts = [p.strip() for p in note.split("|")] - rules.append({"pattern": pattern.strip(), "id": parts[0], "what": parts[1] if len(parts) > 1 else ""}) + rules.append({ + "pattern": pattern.strip(), "id": parts[0], + "what": parts[1] if len(parts) > 1 else "", + "source": parts[2] if len(parts) > 2 else "", + }) + return rules + + +def read_dir(path): + rules = [] + for f in sorted(path.glob("*.txt")): + rules += read_rules(f) return rules @@ -36,43 +47,83 @@ def rule(idx, r, blacklist): return { "id": idx, "pattern": r["pattern"], "patternFlags": REGEX_FLAGS, "patternModeType": 0, "patternExtra": "", "patternExtraFlags": 0, "patternExtraModeType": 0, - "description": f"spamwall {r['id']}: {r['what']}"[:120], + "description": f"SpamWall {r['id']}: {r['what']}"[:120], "priority": BLOCK_PRIORITY if blacklist else ALLOW_PRIORITY, "isBlacklist": blacklist, "flags": FLAGS_CALL_AND_SMS, "channel": "Low", "schedule": "", "blockType": 0, "blockTypeConfig": "", } -def build(cc, strict): - d = ROOT / "rules" / cc - allow, block = read_rules(d / "allow.txt"), read_rules(d / "block.txt") - if strict: - block += read_rules(d / "optional-block.txt") - rules = [rule(i + 100, r, False) for i, r in enumerate(allow)] - rules += [rule(i + 200, r, True) for i, r in enumerate(block)] +def settings(d): return { - "categories": {"all": ["OTHERS", "REGEX_RULES"]}, + "categories": {"all": ["OTHERS"]}, "contacts": {"enabled": True, "isExcusive": False, "permissivePriority": 10, "strictPriority": 0}, "stir": {"enabled": True, "includeUnverified": False, "strictPriority": 0}, "repeatedCall": {"enabled": True, "times": 1, "inXMin": 5}, "dialed": {"enabled": True, "smsEnabled": True, "always": False, "inXDay": 7}, "answered": {"warningAcknowledged": True, "enabled": True, "minDuration": 15, "inXDay": 7}, "recentApps": {"list": [{"pkgName": a["pattern"]} for a in read_rules(d / "allow-apps.txt")], "inXMin": 120}, - "numberRules": {"rules": rules}, } +def rules_part(d, strict): + allow, block = read_dir(d / "allow"), read_dir(d / "block") + if strict: + block += read_dir(d / "optional") + rules = [rule(i + 100, r, False) for i, r in enumerate(allow)] + rules += [rule(i + 200, r, True) for i, r in enumerate(block)] + return {"numberRules": {"rules": rules}} + + +def type_files(d): + out = {} + allow = read_dir(d / "allow") + for kind in ("block", "optional"): + for f in sorted((d / kind).glob("*.txt")): + rs = read_rules(f) + rules = [rule(i + 100, r, False) for i, r in enumerate(allow)] + rules += [rule(i + 200, r, True) for i, r in enumerate(rs)] + out[f"types/{f.stem}"] = {"categories": {"all": ["REGEX_RULES"]}, "numberRules": {"rules": rules}} + return out + + +def files(d): + s = settings(d) + default, strict = rules_part(d, False), rules_part(d, True) + return { + "settings": s, + "rules-default": {"categories": {"all": ["REGEX_RULES"]}, **default}, + "rules-strict": {"categories": {"all": ["REGEX_RULES"]}, **strict}, + "complete": {**s, "categories": {"all": ["OTHERS", "REGEX_RULES"]}, **default}, + **type_files(d), + } + + +def patterns_md(cc, d): + esc = lambda t: t.replace("|", "\\|") + rows = [] + for kind, prio in (("allow", ALLOW_PRIORITY), ("block", BLOCK_PRIORITY), ("optional", BLOCK_PRIORITY)): + for r in read_dir(d / kind): + rows.append(f"| {r['id']} | {kind} | `{esc(r['pattern'])}` | {esc(r['what'])} | {esc(r['source'])} | {prio} |") + head = ("\n" + f"# {cc.upper()} patterns\n\n" + "| ID | Type | Regex | What | Source | Priority |\n|---|---|---|---|---|---|\n") + return head + "\n".join(rows) + "\n" + + def main(): OUT.mkdir(exist_ok=True) - for cc_dir in sorted((ROOT / "rules").iterdir()): - cc = cc_dir.name - for strict in (False, True): - name = f"spamwall-{cc}{'-strict' if strict else ''}" - data = json.dumps(build(cc, strict), indent=1, ensure_ascii=False) + (OUT / "types").mkdir(exist_ok=True) + for old in list(OUT.glob("spamwall-*")) + list((OUT / "types").glob("*")): + old.unlink() + for cc_dir in sorted(p for p in (ROOT / "rules").iterdir() if p.is_dir()): + for name, obj in files(cc_dir).items(): + data = json.dumps(obj, indent=1, ensure_ascii=False) (OUT / f"{name}.json").write_text(data, encoding="utf-8", newline="\n") with gzip.GzipFile(OUT / f"{name}.gz", "wb", mtime=0) as f: f.write(data.encode("utf-8")) print("built", name) + (cc_dir / "patterns.md").write_text(patterns_md(cc_dir.name, cc_dir), encoding="utf-8", newline="\n") if __name__ == "__main__": diff --git a/tools/check.py b/tools/check.py index 29219bd..d5bf536 100644 --- a/tools/check.py +++ b/tools/check.py @@ -1,31 +1,64 @@ """CI checks: regexes compile, no allow/block overlap on official series, -no personal-looking data, and import files match the rule lists.""" +no personal-looking data, every pattern file is well formed, and generated +files match the rule sources.""" import json, re, subprocess, sys from pathlib import Path ROOT = Path(__file__).resolve().parent.parent errors = [] +ids = {} for txt in (ROOT / "rules").rglob("*.txt"): - for n, line in enumerate(txt.read_text(encoding="utf-8").splitlines(), 1): + folder = txt.parent.name + n_rules = 0 + text = txt.read_text(encoding="utf-8") + for n, line in enumerate(text.splitlines(), 1): s = line.split("#")[0].strip() if not s or txt.name == "allow-apps.txt": continue + n_rules += 1 try: re.compile(s) except re.error as e: errors.append(f"{txt}:{n} bad regex: {e}") - if txt.name == "block.txt" and re.match(s, "1600000000") or txt.name == "block.txt" and re.match(s, "1601000000"): + parts = [p.strip() for p in line.partition("#")[2].split("|")] + if len(parts) < 3 or not all(parts): + errors.append(f"{txt}:{n} needs a '# ID | what | source' comment") + continue + if parts[0] != txt.stem: + errors.append(f"{txt}:{n} ID {parts[0]} does not match file name") + if parts[0] in ids: + errors.append(f"{txt}:{n} duplicate ID {parts[0]}") + ids[parts[0]] = txt + if folder == "block" and (re.match(s, "1600000000") or re.match(s, "1601000000")): errors.append(f"{txt}:{n} blocks an official 1600/1601 number") + if folder in {"allow", "block", "optional"}: + if n_rules != 1: + errors.append(f"{txt}: must hold exactly one pattern line") + for key in ("Source:", "False-positive risk:"): + if f"# {key}" not in text: + errors.append(f"{txt}: header comment missing '{key}'") secret = re.compile(r"github_pat_|ghp_|sk-[A-Za-z0-9]{10}|Bearer |password=|api[_-]?key", re.I) for f in ROOT.rglob("*"): if f.is_file() and ".git" not in f.parts and f.suffix in {".txt", ".md", ".json", ".yml", ".py"}: t = f.read_text(encoding="utf-8", errors="ignore") if f.name != "check.py" and secret.search(t): errors.append(f"{f}: looks like a secret") -before = {p.name: p.read_bytes() for p in (ROOT / "spamblocker").glob("*")} + + +def gen(): + paths = [p for p in (ROOT / "spamblocker").rglob("*") if p.is_file()] + list((ROOT / "rules").rglob("patterns.md")) + return {str(p.relative_to(ROOT)): p.read_bytes() for p in paths} + + +before = gen() subprocess.run([sys.executable, "-I", str(ROOT / "tools" / "build_spamblocker.py")], check=True, capture_output=True) -after = {p.name: p.read_bytes() for p in (ROOT / "spamblocker").glob("*")} +after = gen() if before != after: - errors.append("spamblocker/ is out of date: run tools/build_spamblocker.py and commit") + errors.append("generated files are out of date: run tools/build_spamblocker.py and commit") +d = json.loads((ROOT / "spamblocker" / "complete.json").read_text(encoding="utf-8")) +rl = d["numberRules"]["rules"] +shared = {r["priority"] for r in rl if r["isBlacklist"]} & {r["priority"] for r in rl if not r["isBlacklist"]} +if shared: + errors.append(f"allow and block share priority {shared}") print("\n".join(errors) or "all checks passed") sys.exit(1 if errors else 0)