generated from oracle/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 28
test: refactor fake email heuristic to be more optimistic and allow offline tests #1154
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
Merged
+196
−101
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
bb9f32a
chore: refactoring fake email analyzer to be more optimistic in passi…
art1f1c3R f5edd28
test: fake email analyzer tests now run offline in a test environment
art1f1c3R 2caad35
test: adding integration test for email analyzer, included her invali…
art1f1c3R 884766e
test: complete integration test for valid and invalid emails with del…
art1f1c3R fac3714
test: fixed integration test to fail and pass email results as expected
art1f1c3R 309f383
chore: fix copyright and remove comment
art1f1c3R b93367f
test: comment description about test environment variable
art1f1c3R b5cd0ea
test: use defaults.ini instead of test environment
art1f1c3R d680228
chore: use fake_email_defaults_override fixture in test_fake_email.py
tromai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
tests/integration/cases/email_checking_pypi_malware_analyzer/check_emails.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
# Copyright (c) 2025 - 2025, Oracle and/or its affiliates. All rights reserved. | ||
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/. | ||
result=$(sqlite3 --json output/macaron.db "SELECT detect_malicious_metadata_check.detail_information | ||
FROM detect_malicious_metadata_check JOIN check_facts on detect_malicious_metadata_check.id = check_facts.id | ||
JOIN check_result on check_facts.check_result_id = check_result.id JOIN component | ||
ON component.id = check_result.component_id WHERE check_result.check_id = 'mcn_detect_malicious_metadata_1' | ||
AND component.name = 'smooth-operator'" | jq -r ".[0].detail_information | fromjson | .invalid_emails | length > 0") | ||
if [[ "$result" == "false" ]]; then | ||
echo "ERROR: the invalid_emails report for smooth-operator is empty" >&2 | ||
exit 1 | ||
fi | ||
|
||
result=$(sqlite3 --json output/macaron.db "SELECT detect_malicious_metadata_check.detail_information | ||
FROM detect_malicious_metadata_check JOIN check_facts on detect_malicious_metadata_check.id = check_facts.id | ||
JOIN check_result on check_facts.check_result_id = check_result.id JOIN component | ||
ON component.id = check_result.component_id WHERE check_result.check_id = 'mcn_detect_malicious_metadata_1' | ||
AND component.name = 'email-validator'" | jq -r ".[0].detail_information | fromjson | .valid_emails | length > 0") | ||
if [[ "$result" == "false" ]]; then | ||
echo "ERROR: the valid_emails report for email-validator is empty" >&2 | ||
exit 2 | ||
fi | ||
exit 0 |
18 changes: 18 additions & 0 deletions
18
tests/integration/cases/email_checking_pypi_malware_analyzer/policy.dl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* Copyright (c) 2024 - 2025, Oracle and/or its affiliates. All rights reserved. */ | ||
/* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/. */ | ||
|
||
#include "prelude.dl" | ||
|
||
Policy("check-smooth-operator", component_id, "Check smooth-operator artifacts") :- | ||
check_passed(component_id, "mcn_detect_malicious_metadata_1"). | ||
|
||
apply_policy_to("check-smooth-operator", component_id) :- | ||
is_component(component_id, purl), | ||
match("pkg:pypi/smooth-operator", purl). | ||
|
||
Policy("check-email-validator", component_id, "Check email-validator artifacts") :- | ||
check_passed(component_id, "mcn_detect_malicious_metadata_1"). | ||
|
||
apply_policy_to("check-email-validator", component_id) :- | ||
is_component(component_id, purl), | ||
match("pkg:pypi/email-validator", purl). |
31 changes: 31 additions & 0 deletions
31
tests/integration/cases/email_checking_pypi_malware_analyzer/test.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copyright (c) 2024 - 2025, Oracle and/or its affiliates. All rights reserved. | ||
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/. | ||
|
||
description: | | ||
Analyzing two python packages to check if the email address is deliverable and valid. The package smooth-operator is known | ||
to use an invalid email address with an example.com domain. email-validator is known to have a valid, deliverable, email address. | ||
tags: | ||
- macaron-python-package | ||
|
||
steps: | ||
- name: Run macaron analyze against smooth-operator | ||
kind: analyze | ||
options: | ||
command_args: | ||
- -purl | ||
- pkg:pypi/smooth-operator | ||
- name: Run macaron analyze against email-validator | ||
kind: analyze | ||
options: | ||
command_args: | ||
- -purl | ||
- pkg:pypi/email-validator | ||
- name: Query the output database to verify the emails were detected as invalid and valid respectively. | ||
kind: shell | ||
options: | ||
cmd: ./check_emails.sh | ||
- name: Run macaron verify-policy to check the results of the packages still passed. | ||
kind: verify | ||
options: | ||
policy: policy.dl |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.