-
-
Notifications
You must be signed in to change notification settings - Fork 529
DataModel Plugin #2494
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
Merged
DataModel Plugin #2494
Changes from 27 commits
Commits
Show all changes
75 commits
Select commit
Hold shift + click to select a range
fa34c52
added data models
cristinaascari 604738b
updated data models
cristinaascari 1cf2e0a
updated data models
cristinaascari 45b7f10
updated data models
cristinaascari a234319
updated data models
cristinaascari 38c0c29
fix
cristinaascari 3bc44c5
fix
cristinaascari 29f4313
update data models
cristinaascari 1913000
fix
cristinaascari 90187fb
update file data model
cristinaascari b4462a0
update file data model
cristinaascari 4140f2f
updates file data model
cristinaascari 5ab5614
updates file data model
cristinaascari e82f98e
updates file data model
cristinaascari f12776d
updates
cristinaascari 845406c
updates data models
cristinaascari 6f91d84
fix
cristinaascari 0a6529c
fix
cristinaascari 210f008
fix CharFiled max_length
cristinaascari 88376fc
fixes
cristinaascari 858b200
fixes
cristinaascari 7ebe465
Added BaseDataModel
cristinaascari 3717b95
updated BaseDataModel
cristinaascari 8e78524
updates data models
cristinaascari bdddb86
Merge branch 'develop' into datamodel_plugin
cristinaascari e6b289d
updates data models
cristinaascari beb3ff8
added admin data models
cristinaascari 6261ec0
field names fixes
cristinaascari de6b938
fix ip data model
cristinaascari dca7a50
fix ip data model admin
cristinaascari db3f59a
fixes FileDataModel fields
cristinaascari b0119d6
Update external_references field
cristinaascari e0e64da
fix linters
cristinaascari a7beacb
fixes
cristinaascari 0b934ff
updates signature field
cristinaascari dbbd637
updates tags field
cristinaascari f57abe3
fix
cristinaascari 1018903
updates data model admin
cristinaascari 3dab81c
fix
cristinaascari 8c96d36
moved data_model into api_app
cristinaascari 7c81328
moved data_model into api_app
cristinaascari 48bfb83
Added unique_together constraint in IETFReport
cristinaascari c03102a
Merge branch 'develop' into datamodel_plugin
0ssigeno 1b84446
More stuff
0ssigeno a1cba27
Stuff
0ssigeno f853d59
More fixes
0ssigeno c7fa248
More test and logs
0ssigeno 0d85592
Blake
0ssigeno 5dacc79
More
0ssigeno 8e3a3e4
Mini rework
0ssigeno 6914ecd
Blake
0ssigeno 9aeebe3
Blake
0ssigeno f2384be
Fixes
0ssigeno 84421b4
Merge branch 'develop' into datamodel_plugin
0ssigeno dba0c22
Fixes
0ssigeno 89875f5
Fixes
0ssigeno 4ad19ab
Technically we can have some mapping with post processing
0ssigeno bf17b04
bgp_ranking mapping
cristinaascari c2ef65f
more analyzer mappings
cristinaascari b175d72
fixes analyzer mappings
cristinaascari 5cd8f3a
more mappings
cristinaascari fa5a40b
Tor mapping
cristinaascari a084c17
Fix retrieval
0ssigeno 411a3fc
Upgrade data models
0ssigeno bba4baa
More
0ssigeno 6305f44
updates data model
cristinaascari 6cd174f
updates data model
cristinaascari 86faaad
Merge branch 'develop' into datamodel_plugin
cristinaascari 1970b5d
fix migrations
cristinaascari 69f16bd
fixes
cristinaascari c0650d2
black
cristinaascari c686867
fix
cristinaascari 12db34f
Merge branch 'develop' into datamodel_plugin
cristinaascari 7511c3f
black
cristinaascari d3a17c9
Fixes
cristinaascari 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
Empty file.
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,51 @@ | ||
| from django.contrib import admin | ||
|
|
||
| from data_model.models import BaseDataModel, DomainDataModel, FileDataModel, IPDataModel | ||
|
|
||
|
|
||
| @admin.register(BaseDataModel) | ||
| class BaseDataModelAdminView(admin.ModelAdmin): | ||
| list_display = ( | ||
| "evaluation", | ||
| "related_urls", | ||
| "related_threats", | ||
| "family", | ||
| "additional_info", | ||
| ) | ||
|
|
||
|
|
||
| @admin.register(DomainDataModel) | ||
| class DomainDataModelAdminView(BaseDataModelAdminView): | ||
| list_display = BaseDataModelAdminView.list_display + ( | ||
| "ietf_report", | ||
| "rank", | ||
| ) | ||
|
|
||
|
|
||
| @admin.register(IPDataModel) | ||
| class IPDataModelAdminView(BaseDataModelAdminView): | ||
| list_display = BaseDataModelAdminView.list_display + ( | ||
| "ietf_report", | ||
| "asn", | ||
| "asn_rank", | ||
| "certificates", | ||
| "org_name", | ||
| "country", | ||
| "country_code", | ||
| "registered_country", | ||
| "registered_country_code", | ||
| "isp", | ||
| ) | ||
|
|
||
|
|
||
| @admin.register(FileDataModel) | ||
| class FileDataModelAdminView(BaseDataModelAdminView): | ||
| list_display = BaseDataModelAdminView.list_display + ( | ||
| "tags", | ||
| "compromised_hosts", | ||
| "signatures", | ||
| "yara_rules", | ||
| "comments", | ||
| "file_information", | ||
| "stats", | ||
| ) |
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,6 @@ | ||
| from django.apps import AppConfig | ||
|
|
||
|
|
||
| class DataModelConfig(AppConfig): | ||
| default_auto_field = "django.db.models.BigAutoField" | ||
| name = "data_model" |
Empty file.
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,109 @@ | ||
| from django.contrib.postgres import fields as pg_fields | ||
| from django.db import models | ||
|
|
||
|
|
||
| class IETFReport(models.Model): | ||
| rrname = models.CharField(max_length=100) | ||
| rrtype = models.CharField(max_length=100) | ||
| rdata = pg_fields.ArrayField(models.CharField(max_length=100)) | ||
| time_first = models.DateTimeField() | ||
| time_last = models.DateTimeField() | ||
|
|
||
|
|
||
| class BaseDataModel(models.Model): | ||
| evaluation = models.CharField( | ||
| max_length=100, null=True | ||
| ) # classification/verdict/found/score/malscore | ||
| # HybridAnalysisObservable (verdict), BasicMaliciousDetector (malicious), | ||
| # GoogleSafeBrowsing (malicious), Crowdsec (classifications), | ||
| # GreyNoise (classification), Cymru (found), Cuckoo (malscore), | ||
| # Intezer (verdict/sub_verdict), Triage (analysis.score), | ||
| # HybridAnalysisFileAnalyzer (classification_tags) | ||
| related_urls = pg_fields.ArrayField( | ||
| models.URLField(), null=True | ||
| ) # link/external_references/permalink/domains | ||
| # Crowdsec (link), UrlHaus (external_references), BoxJs, | ||
| # Cuckoo (result_url/permalink), Intezer (link/analysis_url), | ||
| # MalwareBazaarFileAnalyzer (permalink/file_information.value), MwDB (permalink), | ||
| # StringsInfo (data), Triage (permalink), UnpacMe (permalink), XlmMacroDeobfuscator, | ||
| # Yara (report.list_el.url/rule_url), Yaraify (link), | ||
| # HybridAnalysisFileAnalyzer (domains), | ||
| # VirusTotalV3FileAnalyzer (data.relationships.contacted_urls/contacted_domains) | ||
| related_threats = pg_fields.ArrayField( | ||
| models.CharField(max_length=100), null=True | ||
| ) # threats/related_threats | ||
cristinaascari marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # GoogleSafeBrowsing, QuarkEngineAPK (crimes.crime) | ||
| family = models.CharField( | ||
| max_length=100, null=True | ||
| ) # family/family_name/malware_family | ||
cristinaascari marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # HybridAnalysisObservable, Intezer (family_name), Cuckoo, MwDB, | ||
| # Triage (analysis.family), UnpacMe (results.malware_id.malware_family), | ||
| # VirusTotalV3FileAnalyzer | ||
| # (attributes.last_analysis_results.list_el.results/attributes.names) | ||
| additional_info = ( | ||
| models.JSONField() | ||
| ) # field for additional information related to a specific analyzer | ||
|
|
||
|
|
||
| class DomainDataModel(BaseDataModel): | ||
| ietf_report = models.ForeignKey( | ||
| IETFReport, on_delete=models.CASCADE, null=True | ||
| ) # pdns | ||
| rank = models.IntegerField(null=True) # Tranco | ||
cristinaascari marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| class IPDataModel(BaseDataModel): | ||
| ietf_report = models.ForeignKey( | ||
| IETFReport, on_delete=models.CASCADE, null=True | ||
| ) # pdns | ||
| asn = models.IntegerField(null=True) # BGPRanking, MaxMind | ||
| asn_rank = models.DecimalField(null=True) # BGPRanking | ||
| certificates = models.JSONField(null=True) # CIRCL_PSSL | ||
| org_name = models.CharField(max_length=100, null=True) # GreyNoise | ||
| country = models.CharField(max_length=100, null=True) # MaxMind, AbuseIPDB | ||
| country_code = models.CharField(max_length=100, null=True) # MaxMind, AbuseIPDB | ||
| registered_country = models.CharField( | ||
| max_length=100, null=True | ||
| ) # MaxMind, AbuseIPDB | ||
| registered_country_code = models.CharField( | ||
| max_length=100, null=True | ||
| ) # MaxMind, AbuseIPDB | ||
| isp = models.CharField(max_length=100, null=True) # AbuseIPDB | ||
| # additional_info | ||
| # behavior = models.CharField(max_length=100, null=True) # Crowdsec | ||
| # noise = models.BooleanField(null=True) # GreyNoise | ||
| # riot = models.BooleanField(null=True) # GreyNoise | ||
| # is_anonymizer = models.BooleanField(null=True) # TorProject, Crowdsec | ||
| # is_tor_exit_node = models.BooleanField(null=True) # TorProject, Crowdsec | ||
cristinaascari marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| class FileDataModel(BaseDataModel): | ||
| tags = pg_fields.ArrayField( | ||
| models.CharField(max_length=100), null=True | ||
| ) # HybridAnalysisFileAnalyzer, MalwareBazaarFileAnalyzer, MwDB, | ||
cristinaascari marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # VirusTotalV3FileAnalyzer (report.data.tags) | ||
| compromised_hosts = pg_fields.ArrayField( | ||
| models.CharField(max_length=100), null=True | ||
| ) # HybridAnalysisFileAnalyzer | ||
cristinaascari marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| signatures = pg_fields.ArrayField( | ||
| models.CharField(max_length=100), null=True | ||
| ) # ClamAvFileAnalyzer, MalwareBazaarFileAnalyzer, Yara (report.list_el.match) | ||
| yara_rules = pg_fields.ArrayField( | ||
| models.JSONField(), null=True | ||
| ) # MalwareBazaarFileAnalyzer, Yaraify (report.data.tasks.static_result) | ||
cristinaascari marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| comments = pg_fields.ArrayField( | ||
| models.CharField(max_length=100), null=True | ||
| ) # MalwareBazaarFileAnalyzer, | ||
| # VirusTotalV3FileAnalyzer (data.relationships.comments) | ||
| file_information = pg_fields.ArrayField( | ||
| models.JSONField(), null=True | ||
| ) # MalwareBazaarFileAnalyzer, OneNoteInfo | ||
cristinaascari marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # (files), QuarkEngineAPK (crimes.confidence, threat_level, total_score) | ||
| # RtfInfo (exploit_equation_editor, exploit_ole2link_vuln) | ||
| stats = pg_fields.ArrayField( | ||
| models.JSONField(), null=True | ||
| ) # PdfInfo (peepdf_stats) | ||
cristinaascari marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # additional_info | ||
| # pdfid_reports = pg_fields.ArrayField(models.JSONField(), null=True) # PdfInfo | ||
| # imphash = models.CharField(max_length=100, null=True) # PeInfo | ||
| # type = models.CharField(max_length=100, null=True) # PeInfo | ||
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 @@ | ||
| # Create your views here. |
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
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.