Files
vulhub/tests/check/test_content.py
Aaron 63285f61aa
Some checks failed
Vulhub Format Check and Lint / format-check (push) Has been cancelled
Vulhub Format Check and Lint / markdown-check (push) Has been cancelled
Vulhub Docker Image CI / longtime-images-test (push) Has been cancelled
Vulhub Docker Image CI / images-test (push) Has been cancelled
first commit
2025-09-06 16:08:15 +08:00

26 lines
753 B
Python

import re
import os
FILE_EXCLUDE_PATTERN = re.compile(r'[/\\]\.(git|idea|vscode|pytest_cache)[/\\]')
def is_textplain(data: bytes):
return b'\x00' not in data
def test_content():
basedir = os.path.realpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', '..'))
for (now_dir, dirs, files) in os.walk(basedir):
for name in files:
filename = os.path.join(now_dir, name)
if FILE_EXCLUDE_PATTERN.search(filename):
continue
with open(filename, 'rb') as f:
data = f.read()
if not is_textplain(data):
continue
assert b'\r\n' not in data, f'CRLF must be convert to LF for Vulhub files, but {filename} did not'