-
-
Notifications
You must be signed in to change notification settings - Fork 547
fix: update YARAify URL in FREE_TO_USE_ANALYZERS playbook #3163
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
Open
YadavAkhileshh
wants to merge
2
commits into
intelowlproject:develop
Choose a base branch
from
YadavAkhileshh:fix-yaraify-url-migration
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
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
59 changes: 59 additions & 0 deletions
59
api_app/playbooks_manager/migrations/0060_update_yaraify_url_free_to_use.py
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,59 @@ | ||
| # This file is a part of IntelOwl https://github.com/intelowlproject/IntelOwl | ||
| # See the file 'LICENSE' for copying permission. | ||
|
|
||
|
|
||
| from django.db import migrations | ||
|
|
||
|
|
||
| def migrate(apps, schema_editor): | ||
| playbook_config = apps.get_model("playbooks_manager", "PlaybookConfig") | ||
| pc = playbook_config.objects.get(name="FREE_TO_USE_ANALYZERS") | ||
|
|
||
| # Update the YARAify URL to the new yarahub endpoint | ||
| if "analyzers" in pc.runtime_configuration: | ||
| if "Yara" in pc.runtime_configuration["analyzers"]: | ||
| yara_config = pc.runtime_configuration["analyzers"]["Yara"] | ||
| if "repositories" in yara_config: | ||
| repositories = yara_config["repositories"] | ||
| # Replace old YARAify URL with new yarahub URL | ||
| old_url = "https://yaraify-api.abuse.ch/download/yaraify-rules.zip" | ||
| new_url = "https://yaraify.abuse.ch/yarahub/yaraify-rules.zip" | ||
|
|
||
| if old_url in repositories: | ||
| index = repositories.index(old_url) | ||
| repositories[index] = new_url | ||
|
|
||
| pc.full_clean() | ||
| pc.save() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please provide a screenshot of the plugin section showing the correct data in the GUI |
||
|
|
||
|
|
||
| def reverse_migrate(apps, schema_editor): | ||
| playbook_config = apps.get_model("playbooks_manager", "PlaybookConfig") | ||
| pc = playbook_config.objects.get(name="FREE_TO_USE_ANALYZERS") | ||
|
|
||
| # Revert to the old YARAify URL | ||
| if "analyzers" in pc.runtime_configuration: | ||
| if "Yara" in pc.runtime_configuration["analyzers"]: | ||
| yara_config = pc.runtime_configuration["analyzers"]["Yara"] | ||
| if "repositories" in yara_config: | ||
| repositories = yara_config["repositories"] | ||
| # Replace new yarahub URL with old YARAify URL | ||
| old_url = "https://yaraify-api.abuse.ch/download/yaraify-rules.zip" | ||
| new_url = "https://yaraify.abuse.ch/yarahub/yaraify-rules.zip" | ||
|
|
||
| if new_url in repositories: | ||
| index = repositories.index(new_url) | ||
| repositories[index] = old_url | ||
|
|
||
| pc.full_clean() | ||
| pc.save() | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
| dependencies = [ | ||
| ("playbooks_manager", "0059_add_ipquery_analyzer_free_to_use"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.RunPython(migrate, reverse_migrate), | ||
| ] | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please check deepsource failures, that suggest to optimize this code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, instead of a lot of if, you can just use .get() and have fewer lines