Skip to content

Feat/sanitize#34

Merged
hyp3rd merged 5 commits intomainfrom
feat/sanitize
Jan 11, 2026
Merged

Feat/sanitize#34
hyp3rd merged 5 commits intomainfrom
feat/sanitize

Conversation

@hyp3rd
Copy link
Owner

@hyp3rd hyp3rd commented Jan 10, 2026

No description provided.

…ation checks

- Introduce pkg/validate with email and URL validation helpers (docs/tests included)
- Email: syntax checks, optional IDN support, TLD requirements, IP-literal policy,
  and domain verification via DNS (MX/A); clear error types (e.g., ErrEmailDomainInvalid,
  ErrEmailDomainLookupFailed, ErrEmailDomainUnverified, ErrEmailIPLiteralNotAllowed)
- URL: scheme allowlist, host allow/block rules, optional IP-literal support,
  redirect policy (depth/allow), reputation checker hook; error types
  (e.g., ErrURLSchemeNotAllowed, ErrURLHostMissing, ErrURLRedirectNotAllowed,
  ErrURLRedirectLoop, ErrURLReputationBlocked)
- Docs: add usage examples and security checklist guidance for input validation
- Chore: extend cspell dictionary with IDN/DNS-related terms
- Deps: add/upgrade golang.org/x/net v0.48.0 and golang.org/x/text v0.32.0
…tion detector

- Introduce pkg/sanitize with focused sanitizers:
  - HTMLSanitizer: escape or strip HTML (optional policy), max-length support
  - MarkdownSanitizer: escape by default; option to allow raw HTML; max-length support
  - SQLSanitizer: modes for Identifiers, Literals, and LIKE patterns; qualified identifiers;
    proper escaping and length caps
  - FilenameSanitizer: control max length, Unicode/spaces, leading dot, and replacement rules
- Add SQLInjectionDetector with normalization + pattern-based detection (configurable)
- Define clear error types for invalid inputs/configuration and length violations
- Docs: expand README and docs/usage with examples; add security-checklist guidance on sanitization
- Chore: extend cspell dictionary with sanitize-related terms
- Tests: unit tests for all sanitizers and the injection detector
Copilot AI review requested due to automatic review settings January 10, 2026 23:25
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds comprehensive input validation and sanitization functionality to the sectools library. The changes introduce two new packages (pkg/validate and pkg/sanitize) with implementations for email/URL validation and HTML/Markdown/SQL/filename sanitization.

Changes:

  • Added email validation with DNS verification, IDN support, and configurable rules
  • Added URL validation with HTTPS-only enforcement, redirect checking, and reputation checks
  • Added HTML/Markdown sanitizers with escape/strip modes and custom policy support
  • Added SQL sanitizer for identifiers, literals, and LIKE patterns with injection detection
  • Added filename sanitizer for secure path segment normalization

Reviewed changes

Copilot reviewed 22 out of 23 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/validate/email.go Email validator with RFC compliance, DNS verification, and IDN support
pkg/validate/url.go URL validator enforcing HTTPS, checking redirects, and reputation
pkg/validate/errors.go Error definitions for validation failures
pkg/validate/email_test.go Test suite for email validation covering core scenarios
pkg/validate/url_test.go Test suite for URL validation with redirect and reputation tests
pkg/sanitize/html.go HTML sanitizer with escape/strip modes and policy support
pkg/sanitize/markdown.go Markdown sanitizer with HTML escaping by default
pkg/sanitize/sql.go SQL sanitizer for identifiers, literals, and LIKE patterns
pkg/sanitize/sql_detect.go Heuristic SQL injection detector with pattern matching
pkg/sanitize/filename.go Filename sanitizer for secure path segments
pkg/sanitize/errors.go Error definitions for sanitization failures
pkg/sanitize/*_test.go Test suites for all sanitization modules
docs/usage.md Documentation for validation and sanitization APIs
docs/security-checklist.md Security guidance for input validation and sanitization
README.md Updated project description and usage examples
go.mod, go.sum Added golang.org/x/net and golang.org/x/text dependencies
cspell.json Added domain-specific terms to spell checker

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

hyp3rd and others added 3 commits January 11, 2026 00:40
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ility

Add a blank line between the empty-local check and the dot-boundary check in pkg/validate/email.go to make the early-return conditions clearer.
No functional changes; whitespace-only.
…o v0.33.0

- go.mod (indirect): golang.org/x/sys v0.39.0 → v0.40.0
- go.mod (indirect): golang.org/x/text v0.32.0 → v0.33.0
- Update go.sum to reflect new dependency versions

No functional code changes; dependency maintenance only
@hyp3rd hyp3rd merged commit af4884f into main Jan 11, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant