-
-
Notifications
You must be signed in to change notification settings - Fork 461
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
PhoneInfoga#995 #2107
PhoneInfoga#995 #2107
Conversation
I still need to update docs and make migrations |
…into PhoneInfoga#995
Docs done |
Hello! @mlodic , this took me sometime to get done. The test is failing here. It pertains to the migration file. I used the dumpplugin comand to create the file. I've crossed checked it with the way previous migrations are written. Still can't seem to find out why this is happening. |
integrations/phoneinfoga/compose.yml
Outdated
environment: | ||
- GIN_MODE=release |
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.
reference to this?
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.
this should run the GIN framework used in release mode. It works fine even without it.
version: '3.7' | ||
|
||
services: | ||
phoneinfoga: | ||
container_name: phoneinfoga | ||
restart: unless-stopped | ||
image: sundowndev/phoneinfoga:latest | ||
espose: | ||
- "5000" | ||
env_file: | ||
- env_file_integrations | ||
environment: | ||
- GIN_MODE=release |
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.
copy/pastes are not required because the compose-tests.yml
is an override of the compose.yml
. Please use other docker analyzers as a reference
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.
so should this file even contain anything as we are using an external service; would it make sense to have an additional dockerfile that clones the repo and builds it for the compose-tests.yml
?
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.
you are right, we could basically leave this almost empty.
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.
should I just mention version: 3.8
in the test yml and rest empty?
api_app/analyzers_manager/migrations/0064_analyzer_config_phoneinfoga.py
Outdated
Show resolved
Hide resolved
api_app/analyzers_manager/migrations/0064_analyzer_config_phoneinfoga.py
Outdated
Show resolved
Hide resolved
integrations/phoneinfoga/compose.yml
Outdated
@@ -0,0 +1,16 @@ | |||
version: '3.7' |
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.
use version 3.8 if you can, like we do in all other docker compose files in the project
the migration error is here:
I think that there is some problem with the IDs
I think that could be the error, I asking to @0ssigeno a second opinion |
Checking |
uhoh, i did it again; overlooked a checkpoint. Made required migrations(agn) |
it worked lol. @mlodic any other changes? |
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.
you can ignore codecov errors, it's a problem of their server. We disabled it.
Considering that I merged Validin PR, could you please adjust the migration here again :P too many PR :P
api_app/analyzers_manager/observable_analyzers/phoneinfoga_scan.py
Outdated
Show resolved
Hide resolved
# 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") | ||
AnalyzerConfig = apps.get_model("analyzers_manager", "AnalyzerConfig") | ||
pc = playbook_config.objects.get(name="FREE_TO_USE_ANALYZERS") | ||
pc.analyzers.add(AnalyzerConfig.objects.get(name="Phoneinfoga").id) | ||
pc.full_clean() | ||
pc.save() | ||
|
||
|
||
def reverse_migrate(apps, schema_editor): | ||
playbook_config = apps.get_model("playbooks_manager", "PlaybookConfig") | ||
AnalyzerConfig = apps.get_model("analyzers_manager", "AnalyzerConfig") | ||
pc = playbook_config.objects.get(name="FREE_TO_USE_ANALYZERS") | ||
pc.analyzers.remove(AnalyzerConfig.objects.get(name="Phoneinfoga").id) | ||
pc.full_clean() | ||
pc.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("playbooks_manager", "0026_add_zippy_scan_to_free_to_use"), | ||
("analyzers_manager", "0065_analyzer_config_phoneinfoga"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(migrate, reverse_migrate), | ||
] |
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.
This is not required because this analyzer is "optional" and it requires to run an additional container.
To avoid to have it providing errors in the base installation, that is the most commonly used, I would not add it in the default playbook. Please remove.
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.
noted. Shouldn't we also mention that such type of analyzers which are free but docker-based
/optional
can't go in default playbook in the docs
or the PR checklist
; to avoid such implementations in future.
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.
sure it would make sense to explicitly say it in the PR template
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.
LOG_LEVEL=INFO | ||
# For phoneinfoga analyzer | ||
# NUMVERIFY_API_KEY= |
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.
isn't there a way to leverage classic Analyzer Secrets for this API key? In that way, every user can configure it and use its own API key.
I don't like to have it configured here because this API key would be shared among all the users. This could be an unwanted behavior.
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.
I'll look into that. Will have to figure out a workaround :'')
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.
hi there! I took a look at their code base. The problem at hand involves the extraction of all the API keys from the from the integration .env
file instead of directly using the key as authorization header when making calls. This is hard coded in their code base.
One work around could be making a new container everytime a new user selects the analyzer. This would have some infra implications but would allow us to have unique containers of the analyzer with its own env file for each individual user. (not a good approach tho)
I have raised an (issue)[https://github.com/sundowndev/phoneinfoga/issues/1393] for further enquiry.
In the meantime we could update the analyzer configs to take API keys from the user in the interface and implement that logic whenever they solve our problem, till then we might have to leverage integration env
only.
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.
thank you for the efforts. I would like to avoid to create complex things for this problem, I like to keep things simple if possible.
I suggest waiting for an answer from them. In case they do not answer within a week, we consider the problem unsolved and so we'll merge your actual PR even if there is that problem. In that case, we would need to specify more information about it in the docs, just to be explicit about this problem with the users.
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.
for sure! In the meantime can you guide me to another issue i can take up?
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.
this is a sightly different analyzer: #1103.
This is a really important source for this project
code quality Co-authored-by: Matteo Lodi <30625432+mlodic@users.noreply.github.com>
…into PhoneInfoga#995
Just to keep a reference, they answered heresundowndev/phoneinfoga#1393) We'll wait them to solve the issue regarding API keys than we'll finish this PR |
@mlodic kindly review. |
let's wait for the tests. If they pass we can merge the PR. Ty! |
closes #995
Description
Add phoneinfoga_scan analyzer
Type of change
Please delete options that are not relevant.
Checklist
develop
_monkeypatch()
was used in its class to apply the necessary decorators.dumpplugin
command and added it in the project as a data migration. ("How to share a plugin with the community")test_files.zip
and you added the default tests for that mimetype in test_classes.py.FREE_TO_USE_ANALYZERS
playbook by following this guide.Black
,Flake
,Isort
) gave 0 errors. If you have correctly installed pre-commit, it does these checks and adjustments on your behalf.tests
folder). All the tests (new and old ones) gave 0 errors.Important Rules
raw json:
{"result":{"valid":true,"number":"33679368229","local_format":"0679368229","international_format":"+33679368229","country_prefix":"+33","country_code":"FR","country_name":"France","location":"","carrier":"Orange France SA","line_type":"mobile"}}