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

[feat] Workspace, bookmarks and Yara trends #119

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
17 changes: 17 additions & 0 deletions bazaar/contrib/sites/migrations/0004_alter_site_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.2.4 on 2021-11-24 15:34

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('sites', '0003_set_site_domain_and_name'),
]

operations = [
migrations.AlterModelOptions(
name='site',
options={'ordering': ['domain'], 'verbose_name': 'site', 'verbose_name_plural': 'sites'},
),
]
36 changes: 36 additions & 0 deletions bazaar/core/migrations/0005_auto_20211124_1534.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Generated by Django 3.2.4 on 2021-11-24 15:34

import bazaar.core.models
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import uuid


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('core', '0004_auto_20210305_1346'),
]

operations = [
migrations.AlterField(
model_name='yara',
name='content',
field=models.TextField(help_text='Paste the content of your Yara rule', validators=[bazaar.core.models.check_yara_rule]),
),
migrations.AlterField(
model_name='yara',
name='title',
field=models.CharField(help_text='The fancy name of your Yara rule', max_length=256),
),
migrations.CreateModel(
name='Bookmark',
fields=[
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('sample', models.CharField(max_length=256)),
('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 3.2.4 on 2022-04-29 16:17

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('core', '0005_auto_20211124_1534'),
('core', '0005_auto_20220125_1346'),
]

operations = [
]
16 changes: 14 additions & 2 deletions bazaar/core/models.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
import uuid

import yara
from django.conf import settings
from django.core.exceptions import ValidationError
from django.db import models
import uuid

from django.db.models.expressions import F
from elasticsearch import Elasticsearch


class Bookmark(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
sample = models.CharField(max_length=256)
owner = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)

@staticmethod
def get_es_index(user):
es_index = f'bookmark_user_{user.id}'
return es_index


def check_yara_rule(rule):
try:
yara.compile(source=rule)
Expand Down
47 changes: 33 additions & 14 deletions bazaar/front/urls.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,46 @@
from django.urls import path
from django.views.generic.base import TemplateView

from bazaar.front.view import HomeView, ReportView, basic_upload_view, similarity_search_view, export_report_view, \
download_sample_view, my_rules_view, my_rule_edit_view, my_rule_create_view, my_rule_delete_view, og_card_view, \
my_retrohunt_view, get_andgrocfg_code, get_genom, basic_url_download_view
from bazaar.front.view import (
HomeView,
ReportView,
add_bookmark_sample_view,
basic_upload_view,
basic_url_download_view,
download_sample_view,
export_report_view,
get_andgrocfg_code,
get_genom,
my_retrohunt_view,
my_rule_create_view,
my_rule_delete_view,
my_rule_edit_view,
og_card_view,
remove_bookmark_sample_view,
similarity_search_view,
workspace_view,
)

app_name = "front"
urlpatterns = [
path("", view=HomeView.as_view(), name="home"),
path("robots.txt", TemplateView.as_view(template_name="robots.txt", content_type="text/plain")),
path("report/<str:sha256>", view=ReportView.as_view(), name="report"),
path("report/<str:sha256>/json", view=export_report_view, name="export_report"),
path("report/<str:sha256>/card", view=og_card_view, name="og_card"),
path("androcfg/<str:sha256>/<path:foo>", view=get_andgrocfg_code, name="get_andgrocfg_code"),
path("androcfg/all", view=get_genom, name="get_genom"),
path("apk/", view=basic_upload_view, name="basic_upload"),
path("url/", view=basic_url_download_view, name="basic_url_download"),
path("apk/<str:sha256>", view=download_sample_view, name="download_sample"),
path("similar/", view=similarity_search_view, name="similarity_search"),
path("similar/<str:sha256>", view=similarity_search_view, name="similarity_search"),
path("rules/", view=my_rules_view, name="my_rules"),
path("rules/new", view=my_rule_create_view, name="my_rule_create"),
path("rules/<str:uuid>/edit", view=my_rule_edit_view, name="my_rule_edit"),
path("apk/<str:sha256>/bookmark/add", view=add_bookmark_sample_view, name="add_bookmark_sample"),
path("apk/<str:sha256>/bookmark/remove", view=remove_bookmark_sample_view,
name="remove_bookmark_sample"),
path("report/<str:sha256>", view=ReportView.as_view(), name="report"),
path("report/<str:sha256>/card", view=og_card_view, name="og_card"),
path("report/<str:sha256>/json", view=export_report_view, name="export_report"),
path("rules/<str:uuid>/delete", view=my_rule_delete_view, name="my_rule_delete"),
path("rules/<str:uuid>/edit", view=my_rule_edit_view, name="my_rule_edit"),
path("rules/<str:uuid>/retro", view=my_retrohunt_view, name="my_rule_retro"),
path("androcfg/<str:sha256>/<path:foo>", view=get_andgrocfg_code, name="get_andgrocfg_code"),
path("androcfg/all", view=get_genom, name="get_genom")
path("rules/new", view=my_rule_create_view, name="my_rule_create"),
path("similar/", view=similarity_search_view, name="similarity_search"),
path("similar/<str:sha256>", view=similarity_search_view, name="similarity_search"),
path("url/", view=basic_url_download_view, name="basic_url_download"),
path("workspace/", view=workspace_view, name="workspace")
]
Loading