File size: 760 Bytes
ffc9a51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import re
from pathlib import Path

# データセットのタグからユーザーネームを検知した時にアラートする

def check_tags(directory_path):
    dir_path = Path(directory_path)
    username_pattern = re.compile(r'(username|user_name)', re.IGNORECASE)

    for file_path in dir_path.glob('*.txt'):
        with open(file_path, 'r') as f:
            tags = f.read().replace(" ", "").strip().split(',')
            for tag in tags:
                if username_pattern.search(tag):
                    print(f"Warning: File {file_path.name} contains tag: {tag}")

if __name__ == "__main__":
    directory_path = r"E:\Dataset\XXXXXX"  # ここにディレクトリへのパスを入力してください
    
    check_tags(directory_path)