Skip to content

[PASO 2.11] Security module + PII masking#35

Merged
mfg1986 merged 8 commits into
developfrom
feature/PASO-2.11_security-module
May 20, 2026
Merged

[PASO 2.11] Security module + PII masking#35
mfg1986 merged 8 commits into
developfrom
feature/PASO-2.11_security-module

Conversation

@mfg1986
Copy link
Copy Markdown
Contributor

@mfg1986 mfg1986 commented May 20, 2026

Summary

  • Add complete security module to @fireflyframework/core (v0.12.0)
  • PII masking: 5 pure functions (maskNif, maskCard, maskPhone, maskEmail, maskIban) + FfPiiMaskPipe + FfPiiMaskDirective with toggle show/hide
  • HTML sanitization: sanitizeHtml(), escapeXss(), stripTags() — regex-based, no DOM dependency
  • CSRF protection: SecurityService (signal-based, SSR-safe) + csrfInterceptor (mutation-only)
  • Provider factory: provideSecurity(config?) following standard DI pattern
  • Types: PiiFieldType, PiiMaskingMode, CsrfConfig, SecurityConfig

Commits (8)

STEP Description
001 Security module type definitions
002 PII masking pure functions (35 tests)
003 FfPiiMaskPipe standalone pipe (8 tests)
004 FfPiiMaskDirective with toggle (11 tests)
005 HTML sanitization functions (32 tests)
006 SecurityService + csrfInterceptor (18 tests)
007 provideSecurity factory + barrel exports
008 Version bump 0.11.0 → 0.12.0

Stats

  • 18 files changed, +1348 lines
  • 104 new tests (security module), 620 total (core)

Test plan

  • pnpm nx build core passes
  • pnpm nx test core — 620/620 tests pass
  • CI pipeline passes (ci, showcase, template — all green)
  • No regressions in existing modules
  • Logs clean (lint warnings are pre-existing, no new errors)

mfg1986 added 8 commits May 20, 2026 14:45
Define PiiFieldType, PiiMaskingMode, CsrfConfig, and SecurityConfig
as the foundational type contracts for the security module (CSRF
protection, input sanitization, and PII masking).
Implement 5 masking functions (maskNif, maskCard, maskPhone,
maskEmail, maskIban) with 35 unit tests covering standard
inputs, edge cases, and null/undefined handling.
Standalone pipe mapping PiiFieldType to masking functions via
Record lookup. Handles null/undefined/empty. 8 unit tests.
Attribute directive that displays masked PII and supports
toggle between masked/unmasked states. Emits visibility
events via ffPiiMaskToggled output. 11 unit tests.
Three sanitization utilities: sanitizeHtml (removes dangerous
tags/attributes/URIs), escapeXss (HTML entity encoding),
stripTags (all tags removed). 32 tests with real XSS vectors.
SecurityService manages CSRF tokens (cookie or manual) and
module config via signal. csrfInterceptor adds CSRF header
on mutation requests only, with pass-through for disabled
config or missing token. 18 unit tests.
…xport from core

- Create provideSecurity(config?) with SECURITY_CONFIG token
- Create security/index.ts barrel exporting full public API
- Re-export security module from packages/core/src/index.ts
- Build OK, 620/620 tests passing
Add security module: provideSecurity(), SecurityService, csrfInterceptor,
PII masking (5 types), FfPiiMaskPipe, FfPiiMaskDirective, HTML sanitization.
Build OK, 620/620 tests pass.
@mfg1986 mfg1986 merged commit 040e934 into develop May 20, 2026
3 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