-
Notifications
You must be signed in to change notification settings - Fork 1
feat: 3종류의 신규 편의성 유틸리티 도구 추가 (URL 추출, PII 마스킹, 해시 생성) #1246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -642,6 +642,70 @@ async def base64_decoder_handler(params: Dict[str, Any]) -> Dict[str, str]: | |
| sentiment_analyzer_handler, | ||
| ) | ||
|
|
||
|
|
||
| async def url_extractor_handler(params: Dict[str, Any]) -> Any: | ||
| text = params.get("text", "") | ||
| urls = re.findall(r"https?://[^\s,.]+(?:[.,][^\s,.]+)*", text) | ||
| return {"urls": urls, "url_count": len(urls)} | ||
|
|
||
| registry.register( | ||
| ToolInfo( | ||
| code="url_extractor", | ||
| name="URL 추출기 (URL Extractor)", | ||
| description="텍스트 본문에서 모든 URL을 추출합니다.", | ||
| category="텍스트 분석", | ||
| parameters={"text": "string"}, | ||
| ), | ||
| url_extractor_handler, | ||
| ) | ||
|
|
||
| async def pii_redactor_handler(params: Dict[str, Any]) -> Any: | ||
| text = params.get("text", "") | ||
| email_pattern = re.compile(r"(?<![a-zA-Z0-9._%+-])[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(?![a-zA-Z0-9._%+-])") | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The tool is advertised as a PII redactor but only recognizes one ASCII email pattern and one hyphenated Korean phone format. That creates a dangerous false assurance for spaces, parentheses, country codes, internationalized email domains, resident-registration-like identifiers, and malformed-but-sensitive values. Either narrow the product name/description to contact-data redaction or implement and document a versioned detector scope, return redaction counts/types, enforce input limits, and add realistic false-positive/false-negative regression cases. |
||
| phone_pattern = re.compile(r"(?<!\d)\d{2,3}-\d{3,4}-\d{4}(?!\d)") | ||
|
|
||
| redacted = email_pattern.sub("[REDACTED EMAIL]", text) | ||
| redacted = phone_pattern.sub("[REDACTED PHONE]", redacted) | ||
| return {"redacted_text": redacted} | ||
|
|
||
| registry.register( | ||
| ToolInfo( | ||
| code="pii_redactor", | ||
| name="개인정보 마스킹 (PII Redactor)", | ||
| description="텍스트에서 이메일 및 전화번호와 같은 개인정보를 식별하고 비식별화 처리합니다.", | ||
| category="보안", | ||
| parameters={"text": "string"}, | ||
| ), | ||
| pii_redactor_handler, | ||
| ) | ||
|
|
||
| async def hash_generator_handler(params: Dict[str, Any]) -> Any: | ||
| text = params.get("text", "") | ||
| algorithm = params.get("algorithm", "sha256").lower() | ||
|
|
||
| if algorithm == "md5": | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do not present MD5/SHA-1 under the |
||
| h = hashlib.md5(usedforsecurity=False) # nosemgrep | ||
| elif algorithm == "sha1": | ||
| h = hashlib.sha1(usedforsecurity=False) # nosemgrep | ||
| elif algorithm == "sha256": | ||
| h = hashlib.sha256() | ||
| else: | ||
| raise ValueError("Unsupported hash algorithm") | ||
|
|
||
| h.update(text.encode("utf-8")) | ||
| return {"hash": h.hexdigest(), "algorithm": algorithm} | ||
|
|
||
| registry.register( | ||
| ToolInfo( | ||
| code="hash_generator", | ||
| name="해시 생성기 (Hash Generator)", | ||
| description="텍스트의 해시값(SHA256, MD5 등)을 생성합니다.", | ||
| category="보안", | ||
| parameters={"text": "string", "algorithm": "string"}, | ||
| ), | ||
| hash_generator_handler, | ||
| ) | ||
|
|
||
| registry.register( | ||
| ToolInfo( | ||
| code="grammar_checker", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add complete docstrings and concrete return types for all three public handlers, then add input-type and bounded-size validation.
params.get(..., "")currently accepts non-string values that can raise implementation-specific exceptions, and these new public functions violate the repository's full-docstring contract.