本文へ移動
cccskills
無料GitHub で公開

pii-in-unstructured

Detects PII in unstructured data including emails, documents, images, and logs using NER-based detection with spaCy and Microsoft Presidio, regex patterns, OCR integration, and confidence scoring. Keywords: PII detection, unstructured data, NER, spaCy, Presidio, OCR, regex, email scanning, document scanning.

インストール方法を見る

含まれるファイル(5)

  • SKILL.md10.2 KB
  • assets/template.md5.3 KB
  • references/standards.md3.6 KB
  • references/workflows.md4.5 KB
  • scripts/process.py14.2 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

PII Detection in Unstructured Data

Overview

Unstructured data — emails, documents, images, chat logs, call transcripts, and system logs — accounts for an estimated 80% of enterprise data and presents the greatest challenge for privacy compliance. Unlike structured databases where personal data resides in known columns, unstructured data contains PII embedded in free text, attached files, scanned images, and metadata. This skill covers detection approaches using Named Entity Recognition (NER), pattern matching, OCR, and hybrid pipelines, with focus on Microsoft Presidio and spaCy as implementation frameworks.

Unstructured Data Sources at Vanguard Financial Services

SourceVolumePII RiskDetection Challenge
Email (Exchange Online)2.1M messages/monthHIGH — names, account numbers, financial data in body and attachmentsMixed text and attachments; forwarded chains contain accumulated PII
SharePoint documents4.2TB across 1,200 sitesHIGH — contracts, KYC docs, customer correspondenceMultiple formats (docx, pdf, xlsx); embedded images
Teams chat890K messages/monthMEDIUM — casual references to customers, internal discussionsShort messages, abbreviations, context-dependent PII
Application logs50GB/dayMEDIUM — IP addresses, user IDs, error messages with PIIHigh volume, mixed with non-PII technical data
Scanned documents45K pages/monthHIGH — passport scans, signed contracts, medical certificatesRequires OCR; variable image quality
Call transcripts8K transcripts/monthHIGH — customers state names, account numbers, personal detailsSpeech-to-text errors, colloquial language
PDF reports12K documents/monthMEDIUM — financial reports may contain customer listsEmbedded tables, charts with PII labels

Detection Architecture

Microsoft Presidio Pipeline

Presidio is an open-source PII detection and anonymisation SDK developed by Microsoft, designed for integration with enterprise data pipelines.

Input Text/Document
       │
       ▼
┌──────────────────┐
│  Pre-processing  │  Format conversion, encoding normalisation,
│  (text extract)  │  OCR for images/scanned PDFs
└──────┬───────────┘
       │
       ▼
┌──────────────────┐
│  Presidio        │  Multiple recognisers run in parallel:
│  Analyzer        │  - NER model (spaCy/transformers)
│                  │  - Pattern recognisers (regex)
│                  │  - Custom recognisers (org-specific)
│                  │  - Context-aware enhancers
└──────┬───────────┘
       │
       ▼
┌──────────────────┐
│  Confidence      │  Each detection assigned confidence score
│  Scoring &       │  Threshold filtering applied
│  Filtering       │  Context enhancement boosts/reduces scores
└──────┬───────────┘
       │
       ▼
┌──────────────────┐
│  Results         │  PII locations, types, confidence scores
│  (structured)    │  Ready for classification, redaction, or alerting
└──────────────────┘

Component Details

NER Model (spaCy/Transformers):

  • spaCy en_core_web_trf model (transformer-based) for English NER
  • Detects: PERSON, ORG, GPE, DATE, MONEY, CARDINAL entities
  • Custom-trained NER for financial domain entities (IBAN, account numbers)

Pattern Recognisers (Regex):

  • UK National Insurance Number: [A-CEGHJ-PR-TW-Z]{2}\d{6}[A-D]
  • Email address: [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}
  • UK phone number: (?:0|\+44)\d{10,11}
  • IBAN: [A-Z]{2}\d{2}[A-Z0-9]{4}\d{7}([A-Z0-9]?){0,16}
  • Credit card: \b(?:\d{4}[-\s]?){3}\d{4}\b (with Luhn validation)
  • IP address (v4): \b(?:\d{1,3}\.){3}\d{1,3}\b
  • Date of birth patterns: \b\d{2}[/-]\d{2}[/-]\d{4}\b
  • Vanguard account: VFS-\d{10}
  • ICD-10 code: [A-Z]\d{2}\.\d{1,4}

Context-Aware Enhancement:

  • Keyword proximity: if "National Insurance" appears within 50 characters of a NINO pattern, boost confidence by 15%
  • Section headers: if detected within a section titled "Personal Details" or "Patient Information", boost confidence by 10%
  • Negative context: if pattern appears within code blocks, SQL queries, or configuration files, reduce confidence by 25%

OCR Integration for Scanned Documents

Pipeline for Image-Based PII Detection

Scanned Document / Image
       │
       ▼
┌──────────────────┐
│  Pre-processing  │  Deskew, denoise, contrast enhancement,
│  (image)         │  resolution upscaling (if < 300 DPI)
└──────┬───────────┘
       │
       ▼
┌──────────────────┐
│  OCR Engine      │  Tesseract OCR (open-source) or
│                  │  Azure AI Document Intelligence (cloud)
│                  │  Output: extracted text with bounding boxes
└──────┬───────────┘
       │
       ▼
┌──────────────────┐
│  Presidio        │  Standard NER + pattern detection
│  Analyzer        │  on OCR-extracted text
└──────┬───────────┘
       │
       ▼
┌──────────────────┐
│  Confidence      │  Adjust for OCR quality:
│  Adjustment      │  OCR confidence < 80% → reduce PII confidence by 20%
│                  │  OCR confidence > 95% → no adjustment
└──────────────────┘

Document Type Detection for Vanguard

Document TypeOCR StrategyExpected PII
Passport scanAzure AI Document Intelligence (ID document model)Full name, DOB, nationality, passport number, photo (biometric)
Utility billGeneral OCR + address pattern recognitionFull name, address, account number
Medical certificateGeneral OCR + health NER modelName, diagnosis, doctor name, dates
Signed contractGeneral OCR + contract template matchingNames, addresses, financial terms, signatures
Cheque imageBanking-specific OCR modelName, account number, sort code, amount

Confidence Scoring Framework

Score Composition

ComponentWeightDescription
Pattern match confidence40%Regex pattern specificity and validation (e.g., Luhn check for credit cards)
NER model confidence30%Model probability score for entity classification
Context enhancement20%Keyword proximity, section header, document type
Source quality10%OCR quality score, document resolution, text extraction confidence

Confidence Thresholds

Confidence LevelScore RangeAction
HIGH85-100%Auto-classify and auto-label; include in discovery report
MEDIUM70-84%Queue for human review; include in discovery report as pending
LOW50-69%Log for audit; do not auto-classify; available for bulk review
BELOW THRESHOLD< 50%Suppress; do not report unless specifically queried

Implementation Patterns

Pattern 1: Email Scanning Pipeline

# Conceptual pipeline for Exchange Online email scanning
# 1. Microsoft Graph API retrieves email messages
# 2. Extract body text (HTML → plain text conversion)
# 3. Extract attachment text (document parsing)
# 4. Run Presidio analyzer on combined text
# 5. Map findings to email metadata (sender, recipients, date)
# 6. Apply classification labels via Microsoft Purview

Pattern 2: Log File Scanning

For application logs, specific patterns dominate:

  • IP addresses in access logs
  • User IDs and session tokens in authentication logs
  • Email addresses in error messages
  • Stack traces containing file paths with usernames

Log scanning requires higher false-positive tolerance and volume-optimised processing.

Pattern 3: Chat Message Scanning

Teams/Slack messages present unique challenges:

  • Short messages with minimal context
  • Abbreviations and informal language
  • Customer names mentioned without surrounding keywords
  • Account numbers shared in fragments across messages

Strategy: scan message threads rather than individual messages to capture context.

Accuracy Benchmarks

Expected Performance by Data Source

SourcePrecision TargetRecall TargetKey Challenges
Email body text> 92%> 88%Forwarded chains, signatures, disclaimers
SharePoint documents (Office formats)> 90%> 85%Embedded tables, headers/footers
Scanned documents (OCR)> 85%> 80%OCR errors, handwriting, poor image quality
Application logs> 88%> 82%IP address over-detection, reference number ambiguity
Chat messages> 80%> 75%Short context, informal language, abbreviations
Call transcripts> 82%> 78%Speech-to-text errors, overlapping speech, accents

Integration Points

  • auto-data-discovery: Unstructured PII detection complements structured data discovery platforms
  • data-labeling-system: Detected PII drives automatic sensitivity label application
  • classification-policy: Detection results feed into classification tier assignment
  • data-inventory-mapping: Unstructured PII findings expand the data inventory to include document repositories and email systems

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Implements 42 CFR Part 2 protections for substance use disorder patient records. Covers written consent requirements stricter than HIPAA, re-disclosure prohibition, court order procedures, qualified service organization agreements, and 2024 amendments aligning Part 2 with HIPAA. Keywords: 42 CFR Part 2, substance use disorder, SUD records, re-disclosure, consent, Part 2 amendments.

日本語の概要は準備中です。原文の説明を表示しています。

mukul975/Privacy-Data-Protection-Skills3032026年3月17日 更新

Guides assessment of third-country adequacy decisions under GDPR Article 45 for international data transfers. Covers the current EC adequacy decisions list, adequacy assessment criteria, partial adequacy handling, and monitoring of adequacy decision reviews. Keywords: adequacy decision, Article 45, third country, adequate protection, EC adequacy list.

日本語の概要は準備中です。原文の説明を表示しています。

mukul975/Privacy-Data-Protection-Skills3032026年3月17日 更新

Implements age-gating mechanisms for online services to restrict access based on user age. Covers hard gates versus soft gates, neutral age prompts, re-verification triggers, circumvention prevention, and regulatory requirements under GDPR, COPPA, UK Online Safety Act, and DSA. Keywords: age gate, age restriction, neutral prompt, children, online services, access control.

日本語の概要は準備中です。原文の説明を表示しています。

mukul975/Privacy-Data-Protection-Skills3032026年3月17日 更新

Evaluates and implements age estimation and verification technologies for online services. Covers facial age estimation, digital ID verification, self-declaration with risk assessment, AI-based age estimation, and the accuracy versus privacy tradeoff. Includes ICO guidance and euCONSENT framework. Keywords: age verification, age estimation, facial analysis, digital ID, children, online safety.

日本語の概要は準備中です。原文の説明を表示しています。

mukul975/Privacy-Data-Protection-Skills3032026年3月17日 更新

Preparing EU AI Act compliance documentation for high-risk AI systems. Covers Annex III classification, technical documentation under Art. 11, conformity assessment, risk management systems, and CE marking requirements. Keywords: EU AI Act, high-risk AI, Annex III, conformity assessment, CE marking.

日本語の概要は準備中です。原文の説明を表示しています。

mukul975/Privacy-Data-Protection-Skills3032026年3月17日 更新

Implements GDPR Art. 22 automated decision-making and AI Act Art. 14 human oversight requirements for AI systems. Covers identification of solely automated decisions, meaningful human intervention design, logic explanation mechanisms, and contestation procedures. Keywords: Art. 22, automated decision, human oversight, AI Act, profiling, contestation.

日本語の概要は準備中です。原文の説明を表示しています。

mukul975/Privacy-Data-Protection-Skills3032026年3月17日 更新

mukul975 のスキルをすべて見る

このスキルの問題を報告する