Ensure safe ExifTool usage: require >= 12.24 (#1399)
* feat: add version verification for ExifTool to ensure security compliance * fix: improve ExifTool version verification ---------
This commit is contained in:
@@ -1,7 +1,11 @@
|
|||||||
import json
|
import json
|
||||||
import subprocess
|
|
||||||
import locale
|
import locale
|
||||||
from typing import BinaryIO, Any, Union
|
import subprocess
|
||||||
|
from typing import Any, BinaryIO, Union
|
||||||
|
|
||||||
|
|
||||||
|
def _parse_version(version: str) -> tuple:
|
||||||
|
return tuple(map(int, (version.split("."))))
|
||||||
|
|
||||||
|
|
||||||
def exiftool_metadata(
|
def exiftool_metadata(
|
||||||
@@ -13,6 +17,24 @@ def exiftool_metadata(
|
|||||||
if not exiftool_path:
|
if not exiftool_path:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
# Verify exiftool version
|
||||||
|
try:
|
||||||
|
version_output = subprocess.run(
|
||||||
|
[exiftool_path, "-ver"],
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
check=True,
|
||||||
|
).stdout.strip()
|
||||||
|
version = _parse_version(version_output)
|
||||||
|
min_version = (12, 24)
|
||||||
|
if version < min_version:
|
||||||
|
raise RuntimeError(
|
||||||
|
f"ExifTool version {version_output} is vulnerable to CVE-2021-22204. "
|
||||||
|
"Please upgrade to version 12.24 or later."
|
||||||
|
)
|
||||||
|
except (subprocess.CalledProcessError, ValueError) as e:
|
||||||
|
raise RuntimeError("Failed to verify ExifTool version.") from e
|
||||||
|
|
||||||
# Run exiftool
|
# Run exiftool
|
||||||
cur_pos = file_stream.tell()
|
cur_pos = file_stream.tell()
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user