Skip to content
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

[imagecompare] mypy #36044

Merged
merged 2 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Packs/SuspiciousDomainHunting/ReleaseNotes/1_0_5.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

#### Scripts

##### imagecompare

- Fixed an issue where the script would fail with an ImportError.
- Updated the Docker image to: *demisto/processing-image-file:1.0.0.108564*.
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
import demistomock as demisto # noqa: F401
from CommonServerPython import * # noqa: F401

from cv2 import cv2
import cv2
from skimage.metrics import structural_similarity as compare_ssim


def calculate_mse(image_path1, image_path2):
# Load the images
img1 = cv2.imread(image_path1)
img2 = cv2.imread(image_path2)
img1 = cv2.imread(image_path1) # pylint: disable=[E1101]
img2 = cv2.imread(image_path2) # pylint: disable=[E1101]

# Check if the images are loaded successfully
if img1 is None or img2 is None:
return None

# Calculate Mean Squared Error (MSE)
mse = ((img1 - img2) ** 2).mean()
mse = ((img1 - img2) ** 2).mean() # type: ignore[operator]
return mse


def calculate_ssim(image_path1, image_path2):
# Load the images
img1 = cv2.imread(image_path1)
img2 = cv2.imread(image_path2)
img1 = cv2.imread(image_path1) # pylint: disable=[E1101]
img2 = cv2.imread(image_path2) # pylint: disable=[E1101]

# Check if the images are loaded successfully
if img1 is None or img2 is None:
return None

# Convert images to grayscale
img1_gray = cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY)
img2_gray = cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY)
img1_gray = cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY) # pylint: disable=[E1101]
img2_gray = cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY) # pylint: disable=[E1101]

# Calculate Structural Similarity Index (SSIM)
ssim = compare_ssim(img1_gray, img2_gray)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ args:
scripttarget: 0
subtype: python3
runonce: false
dockerimage: demisto/processing-image-file:1.0.0.89250
dockerimage: demisto/processing-image-file:1.0.0.108564
runas: DBotWeakRole
engineinfo: {}
tests:
Expand Down
2 changes: 1 addition & 1 deletion Packs/SuspiciousDomainHunting/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Suspicious Domain Hunting",
"description": "This pack provides all the necessary tools for the Suspicious Domain Hunting use case. It uses the CertStream integration to ingest new SSL certificates and alert for type-squatting domains with SSL certificate, these alerts are then analyzed and mitigated.",
"support": "community",
"currentVersion": "1.0.4",
"currentVersion": "1.0.5",
"author": "Cortex XSOAR",
"url": "https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/bd-p/Cortex_XSOAR_Discussions",
"email": "",
Expand Down
Loading