[PR #13] [CLOSED] Add Global Allowlist for Safe IPs/Domains #16

Closed
opened 2026-03-02 11:45:01 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/karant-dev/AutoRedact/pull/13
Author: @Copilot
Created: 12/12/2025
Status: Closed

Base: mainHead: copilot/add-global-allowlist-feature


📝 Commits (4)

  • c7f2cdf Initial plan
  • 098f72a Initial plan for Global Allowlist feature
  • a0f7d9d Add Global Allowlist feature for safe values that should skip redaction
  • 68f7f2c Address code review feedback: consistent trim logic and O(1) Set lookups for allowlist

📊 Changes

12 files changed (+346 additions, -47 deletions)

View changed files

📝 package-lock.json (+0 -12)
📝 src/App.tsx (+16 -5)
📝 src/components/Header.tsx (+17 -1)
src/components/SettingsModal.tsx (+143 -0)
src/constants/allowlist.ts (+41 -0)
src/contexts/AllowlistContext.tsx (+46 -0)
src/contexts/AllowlistContextDef.ts (+10 -0)
src/hooks/useAllowlist.ts (+10 -0)
📝 src/hooks/useBatch.ts (+2 -2)
📝 src/hooks/useOCR.ts (+28 -13)
📝 src/main.tsx (+4 -1)
📝 src/utils/ocr.ts (+29 -13)

📄 Description

Users needed a way to prevent common safe values (localhost IPs, public DNS) from being redacted. This adds a configurable allowlist with sensible defaults and case-insensitive matching.

Changes

Allowlist Configuration (src/constants/allowlist.ts)

  • Default safe values: 127.0.0.1, localhost, 0.0.0.0, ::1, private ranges (192.168.x.x, 10.0.0.1), public DNS (8.8.8.8, 1.1.1.1)
  • O(1) Set-based lookups for performance

State Management

  • AllowlistContext with localStorage persistence
  • useAllowlist hook for component access

OCR Integration

  • useOCR.ts and utils/ocr.ts filter matches against allowlist before redaction
  • Works for both single image and batch processing

UI

  • Settings button (gear icon) in Header
  • Settings Modal to add/remove/reset allowlist values
// Filter logic applied to all match categories
const allowlistSet = createAllowlistSet(allowlist);
const filterAllowlisted = <T extends { text: string }>(matches: T[]): T[] =>
    matches.filter(m => !isAllowlisted(m.text, allowlistSet));

Screenshots

Settings Button

Settings Button

Settings Modal

Settings Modal

Additional Fix

Changed imageRef to loadedImage state in useOCR to resolve pre-existing lint error (ref accessed during render).

Original prompt

This section details on the original issue you should resolve

<issue_title>[Feat]: Global Allowlist (Safe IPs/Domains)</issue_title>
<issue_description>### Is your feature request related to a problem?
AutoRedact keeps redacting my localhost IPs (127.0.0.1) and public DNS (8.8.8.8) which are safe to share.

Describe the solution you'd like

Add a "Safe Values" list in Settings.

  • Logic: If detected_text is in allow_list, skip redaction.
  • Have an opinionated default like safe IPs (ex: 127.0.0.1, localhost, local IP range, etc), but user can add more.

Describe alternatives you've considered

Deleting the redaction box manually every time.

Additional context

Should support exact strings (case-insensitive).</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/karant-dev/AutoRedact/pull/13 **Author:** [@Copilot](https://github.com/apps/copilot-swe-agent) **Created:** 12/12/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `copilot/add-global-allowlist-feature` --- ### 📝 Commits (4) - [`c7f2cdf`](https://github.com/karant-dev/AutoRedact/commit/c7f2cdf3fbc71ee388bffe830984975701a1e187) Initial plan - [`098f72a`](https://github.com/karant-dev/AutoRedact/commit/098f72af0aa4600270d4e62a1e7537d87438ec5d) Initial plan for Global Allowlist feature - [`a0f7d9d`](https://github.com/karant-dev/AutoRedact/commit/a0f7d9d3bfe8906268490d4522700d53f190ec5e) Add Global Allowlist feature for safe values that should skip redaction - [`68f7f2c`](https://github.com/karant-dev/AutoRedact/commit/68f7f2c000445e42fad07fca39cd57aa3e89e04a) Address code review feedback: consistent trim logic and O(1) Set lookups for allowlist ### 📊 Changes **12 files changed** (+346 additions, -47 deletions) <details> <summary>View changed files</summary> 📝 `package-lock.json` (+0 -12) 📝 `src/App.tsx` (+16 -5) 📝 `src/components/Header.tsx` (+17 -1) ➕ `src/components/SettingsModal.tsx` (+143 -0) ➕ `src/constants/allowlist.ts` (+41 -0) ➕ `src/contexts/AllowlistContext.tsx` (+46 -0) ➕ `src/contexts/AllowlistContextDef.ts` (+10 -0) ➕ `src/hooks/useAllowlist.ts` (+10 -0) 📝 `src/hooks/useBatch.ts` (+2 -2) 📝 `src/hooks/useOCR.ts` (+28 -13) 📝 `src/main.tsx` (+4 -1) 📝 `src/utils/ocr.ts` (+29 -13) </details> ### 📄 Description Users needed a way to prevent common safe values (localhost IPs, public DNS) from being redacted. This adds a configurable allowlist with sensible defaults and case-insensitive matching. ## Changes ### Allowlist Configuration (`src/constants/allowlist.ts`) - Default safe values: `127.0.0.1`, `localhost`, `0.0.0.0`, `::1`, private ranges (`192.168.x.x`, `10.0.0.1`), public DNS (`8.8.8.8`, `1.1.1.1`) - O(1) Set-based lookups for performance ### State Management - `AllowlistContext` with localStorage persistence - `useAllowlist` hook for component access ### OCR Integration - `useOCR.ts` and `utils/ocr.ts` filter matches against allowlist before redaction - Works for both single image and batch processing ### UI - Settings button (gear icon) in Header - Settings Modal to add/remove/reset allowlist values ```typescript // Filter logic applied to all match categories const allowlistSet = createAllowlistSet(allowlist); const filterAllowlisted = <T extends { text: string }>(matches: T[]): T[] => matches.filter(m => !isAllowlisted(m.text, allowlistSet)); ``` ## Screenshots ### Settings Button ![Settings Button](https://github.com/user-attachments/assets/84cbc31c-3c18-4054-a190-714fc24f2b58) ### Settings Modal ![Settings Modal](https://github.com/user-attachments/assets/730ce73c-83d4-47c6-8f1d-09234ca83315) ## Additional Fix Changed `imageRef` to `loadedImage` state in `useOCR` to resolve pre-existing lint error (ref accessed during render). <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>[Feat]: Global Allowlist (Safe IPs/Domains)</issue_title> > <issue_description>### Is your feature request related to a problem? > AutoRedact keeps redacting my localhost IPs (127.0.0.1) and public DNS (8.8.8.8) which are safe to share. > > ### Describe the solution you'd like > Add a "Safe Values" list in Settings. > - Logic: If detected_text is in allow_list, skip redaction. > - Have an opinionated default like safe IPs (ex: 127.0.0.1, localhost, local IP range, etc), but user can add more. > > ### Describe alternatives you've considered > Deleting the redaction box manually every time. > > ### Additional context > Should support exact strings (case-insensitive).</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes karant-dev/AutoRedact#11 <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-02 11:45:01 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/AutoRedact#16
No description provided.