Skip to content

Commit 632b376

Browse files
timiagamatimiagama
andauthored
Release v0.1.0 (#2)
* Initial release (inaccurate docs) * Initial release with updated documentation * Initial release - workflow patch * Removed postinstall script to stop workflow errors * Snyk workflow now correctly calls npm lint * npm-publish workflow now only triggers publish onr elease * Fixed issues with workflow badges * Slight modification to readme.md --------- Co-authored-by: timiagama <107476562+timi-agama@users.noreply.github.com>
1 parent d2532a3 commit 632b376

File tree

64 files changed

+16466
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+16466
-0
lines changed

.eslintrc.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"extends": [
3+
"plugin:security-node/recommended",
4+
"plugin:promise/recommended"
5+
],
6+
"plugins": [
7+
"security-node",
8+
"promise",
9+
"no-unsanitized",
10+
"sonarjs"
11+
],
12+
"parser": "@typescript-eslint/parser",
13+
"parserOptions": {
14+
"ecmaVersion": 2022,
15+
"sourceType": "module",
16+
"project": "./tsconfig.eslint.json",
17+
"warnOnUnsupportedTypeScriptVersion": false
18+
},
19+
"rules": {
20+
"no-unsanitized/method": "error",
21+
"no-unsanitized/property": "error",
22+
"eol-last": ["error", "always"],
23+
"quotes": ["error", "single"],
24+
25+
"security-node/detect-child-process": "error",
26+
"security-node/detect-eval-with-expr": "error",
27+
"security-node/detect-non-literal-require-calls": "warn",
28+
"security-node/non-literal-reg-expr": "error",
29+
"security-node/detect-html-injection": "error",
30+
"security-node/detect-sql-injection": "error",
31+
"security-node/detect-unhandled-async-errors": "error",
32+
"security-node/detect-possible-timing-attacks": "error",
33+
"security-node/detect-nosql-injection": "error",
34+
"security-node/detect-security-missconfiguration-cookie": "error",
35+
"security-node/detect-dangerous-redirects": "error",
36+
"security-node/detect-insecure-randomness": "error",
37+
38+
"sonarjs/no-all-duplicated-branches": "error",
39+
"sonarjs/no-element-overwrite": "error",
40+
"sonarjs/no-identical-conditions": "error",
41+
"sonarjs/no-identical-expressions": "error",
42+
"sonarjs/no-one-iteration-loop": "error",
43+
"sonarjs/no-use-of-empty-return-value": "error",
44+
"sonarjs/no-extra-arguments": "error",
45+
"sonarjs/no-identical-functions": "error",
46+
"sonarjs/no-duplicated-branches": "error",
47+
"sonarjs/cognitive-complexity": [
48+
"error",
49+
15
50+
]
51+
}
52+
}

.github/dependabot.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
version: 2
2+
updates:
3+
# Enable version updates for npm
4+
- package-ecosystem: "npm"
5+
# Look for package.json and package-lock.json in the root directory
6+
directory: "/"
7+
# Check for updates once a week
8+
schedule:
9+
interval: "weekly"
10+
# Specify labels for npm pull requests
11+
labels:
12+
- "npm"
13+
- "dependencies"
14+
# Set maximum number of open pull requests
15+
open-pull-requests-limit: 10
16+
# Allow up to 5 minor version updates
17+
versioning-strategy: widen
18+
# Group minor and patch updates together
19+
groups:
20+
dev-dependencies:
21+
patterns:
22+
- "@types/*"
23+
- "eslint*"
24+
- "prettier"
25+
- "jest"
26+
update-types:
27+
- "minor"
28+
- "patch"
29+
30+
# Enable version updates for GitHub Actions
31+
- package-ecosystem: "github-actions"
32+
directory: "/"
33+
schedule:
34+
interval: "weekly"
35+
# Specify labels for GitHub Actions pull requests
36+
labels:
37+
- "github-actions"
38+
- "dependencies"
39+
# Set maximum number of open pull requests
40+
open-pull-requests-limit: 5
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: "CodeQL Analysis"
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- main
7+
- master
8+
pull_request:
9+
branches:
10+
- main
11+
- master
12+
schedule:
13+
- cron: '0 0 * * 1' # Run weekly on Mondays
14+
15+
jobs:
16+
analyze:
17+
name: Analyze
18+
runs-on: ubuntu-latest
19+
permissions:
20+
actions: read
21+
contents: read
22+
security-events: write
23+
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
language: [ 'javascript' ]
28+
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v4
32+
33+
- name: Initialize CodeQL
34+
uses: github/codeql-action/init@v2
35+
with:
36+
languages: ${{ matrix.language }}
37+
38+
- name: Setup Node.js
39+
uses: actions/setup-node@v4
40+
with:
41+
node-version: '18'
42+
cache: 'npm'
43+
44+
- name: Install dependencies
45+
run: npm ci
46+
47+
- name: Build
48+
run: npm run build
49+
50+
- name: Perform CodeQL Analysis
51+
uses: github/codeql-action/analyze@v3
52+

.github/workflows/npm-publish.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# .github/workflows/npm-publish.yml
2+
name: Build and Publish
3+
4+
on:
5+
push:
6+
branches-ignore:
7+
- main
8+
- master
9+
pull_request:
10+
branches:
11+
- main
12+
- master
13+
release:
14+
types: [created]
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v3
21+
- uses: actions/setup-node@v3
22+
with:
23+
node-version: '18.x'
24+
registry-url: 'https://registry.npmjs.org'
25+
26+
- name: Install dependencies
27+
run: npm ci
28+
29+
- name: Lint
30+
run: npm run lint
31+
32+
- name: Test
33+
run: npm test
34+
35+
- name: Build
36+
run: npm run build
37+
38+
publish:
39+
needs: build
40+
if: github.event_name == 'release'
41+
runs-on: ubuntu-latest
42+
steps:
43+
- uses: actions/checkout@v3
44+
- uses: actions/setup-node@v3
45+
with:
46+
node-version: '18.x'
47+
registry-url: 'https://registry.npmjs.org'
48+
49+
- name: Install dependencies
50+
run: npm ci
51+
52+
- name: Build
53+
run: npm run build
54+
55+
- name: Publish to NPM
56+
run: npm publish
57+
env:
58+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/snyk.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Snyk Security Checks
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- main
7+
- master
8+
pull_request:
9+
branches:
10+
- main
11+
- master
12+
schedule:
13+
- cron: '0 0 * * 0' # Weekly scan on Sundays
14+
15+
jobs:
16+
security-checks:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Setup Node.js
25+
uses: actions/setup-node@v3
26+
with:
27+
node-version: '18'
28+
cache: 'npm'
29+
30+
- name: Install dependencies
31+
run: npm ci
32+
33+
- name: Run ESLint security checks
34+
run: npm run lint
35+
36+
- name: Run tests with coverage
37+
run: npm run test
38+
39+
- name: Snyk security scan
40+
uses: snyk/actions/node@master
41+
env:
42+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
43+
with:
44+
args: --all-projects --org=${{ secrets.SNYK_ORG }} --severity-threshold=high

.github/workflows/sonar.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: SonarQube Analysis
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- main
7+
- master
8+
pull_request:
9+
branches:
10+
- main
11+
- master
12+
types: [opened, synchronize, reopened]
13+
schedule:
14+
- cron: '0 0 * * 0' # Weekly scan on Sundays
15+
16+
jobs:
17+
sonarqube:
18+
name: SonarQube
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
24+
25+
- name: Setup Node.js
26+
uses: actions/setup-node@v3
27+
with:
28+
node-version: '18'
29+
cache: 'npm'
30+
31+
- name: Install dependencies
32+
run: npm ci
33+
34+
- name: Run tests with coverage
35+
run: npm run test
36+
37+
- name: SonarQube Scan
38+
uses: SonarSource/sonarqube-scan-action@v5
39+
env:
40+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
41+
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL || 'https://sonarcloud.io' }}

.gitignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Dependency directories
2+
node_modules/
3+
4+
# Built output
5+
dist/
6+
7+
# Environment files
8+
.env
9+
10+
# Logs
11+
logs
12+
*.log
13+
npm-debug.log*
14+
15+
# Coverage directory used by tools like istanbul
16+
coverage
17+
18+
# IDE specific files
19+
.idea/
20+
.vscode/
21+
*.swp
22+
*.swo
23+
24+
# OS specific files
25+
.DS_Store
26+
Thumbs.db
27+
28+
# Jest coverage reports
29+
coverage/

.scannerwork/.sonar_lock

Whitespace-only changes.

.scannerwork/report-task.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
projectKey=timiagama_nigerian-mobile-validator
2+
serverUrl=http://localhost:9000
3+
serverVersion=25.3.0.104237
4+
dashboardUrl=http://localhost:9000/dashboard?id=timiagama_nigerian-mobile-validator
5+
ceTaskId=a57b8f19-5721-4b8f-b17e-5a6f3dda7c06
6+
ceTaskUrl=http://localhost:9000/api/ce/task?id=a57b8f19-5721-4b8f-b17e-5a6f3dda7c06

CHANGELOG.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Changelog
2+
3+
All notable changes to the Nigerian Mobile Validator will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [0.1.0] - 2025-03-31
9+
10+
### Added
11+
- Initial release of Nigerian Mobile Validator
12+
- Validation based on NCC March 2025 numbering plan
13+
- Support for network codes 700-919
14+
- Telco identification for all active Nigerian operators
15+
- Stream-based API for reactive updates
16+
- Batch validation for processing multiple numbers
17+
- CSV export functionality
18+
- TypeScript declarations for better type safety
19+
- Comprehensive unit and integration tests
20+
- Documentation with usage examples
21+
- Enhanced security features through new `ValidatorSecurity` class
22+
- Rolling window rate limiting to prevent abuse
23+
- Input sanitization against control characters and overly long inputs
24+
- Fast rejection mechanism for obviously invalid inputs
25+
- PII (Personally Identifiable Information) protection in logs
26+
- Automatic phone number masking in all logging
27+
- Memory leak prevention with EventEmitter listener limits
28+
- Improved test data generation with NetworkAccessCode enums
29+
- Comprehensive property-based testing for validation robustness
30+
- Integration tests for security features
31+
- Event emitter for reactive validation and lifecycle management
32+
33+
### Technical Features
34+
- Map-based lookup for optimal performance
35+
- Lazy loading to reduce memory footprint
36+
- Sanitization of common input mistakes
37+
- Support for multiple number formats
38+
- Detailed validation status messages
39+
- Complex number range validations
40+
- Security protection against denial of service
41+
- PII masking for all phone numbers in logs
42+
- Prevention for memory leaks in event handling
43+
- Input sanitization against malicious patterns
44+
- Maximum input length restrictions

0 commit comments

Comments
 (0)