diff --git a/iot_inspector/admin.py b/iot_inspector/admin.py
index be6f64ba..c740abdd 100644
--- a/iot_inspector/admin.py
+++ b/iot_inspector/admin.py
@@ -10,7 +10,6 @@
client_generate_report,
client_get_report_link,
client_login,
- client_upload_firmware,
get_default_product_group,
)
from .models import AnalysisRequest, IOTUser
@@ -35,9 +34,7 @@ def validate_status(self, request, queryset):
if not analysis_request.firmware_uuid:
client = client_login(iot_user)
default_product_group = get_default_product_group(client)
- firmware = client_upload_firmware(
- client, analysis_request, default_product_group
- )
+ firmware = {"id": "ONEKEY removed"} # TODO: Find a replacement for ONKEY firmware analisys
firmware_uuid = firmware["id"]
analysis_request.firmware_uuid = firmware_uuid
analysis_request.status = True
diff --git a/iot_inspector/helpers.py b/iot_inspector/helpers.py
index 6d978f90..d89caf12 100644
--- a/iot_inspector/helpers.py
+++ b/iot_inspector/helpers.py
@@ -7,7 +7,6 @@
from decouple import config
from django.core.files.storage import FileSystemStorage
from django.core.signing import Signer
-from onekey_client import Client, FirmwareMetadata
from testing_platform import settings
@@ -111,18 +110,6 @@ def get_default_product_group(client):
return default_product_group
-def client_upload_firmware(client, analysis_request, default_product_group):
- metadata = FirmwareMetadata(
- name=analysis_request.name,
- vendor_name=analysis_request.vendor_name,
- product_name=analysis_request.product_name,
- product_group_id=default_product_group["id"],
- )
- firmware_path = Path(analysis_request.file.path)
- res = client.upload_firmware(metadata, firmware_path, enable_monitoring=True)
- return res
-
-
def client_get_or_generate_report_config(client):
GET_ALL_REPORT_CONFIGS = """
query {
diff --git a/iot_inspector/helpers_old.py b/iot_inspector/helpers_old.py
index 6d978f90..d89caf12 100644
--- a/iot_inspector/helpers_old.py
+++ b/iot_inspector/helpers_old.py
@@ -7,7 +7,6 @@
from decouple import config
from django.core.files.storage import FileSystemStorage
from django.core.signing import Signer
-from onekey_client import Client, FirmwareMetadata
from testing_platform import settings
@@ -111,18 +110,6 @@ def get_default_product_group(client):
return default_product_group
-def client_upload_firmware(client, analysis_request, default_product_group):
- metadata = FirmwareMetadata(
- name=analysis_request.name,
- vendor_name=analysis_request.vendor_name,
- product_name=analysis_request.product_name,
- product_group_id=default_product_group["id"],
- )
- firmware_path = Path(analysis_request.file.path)
- res = client.upload_firmware(metadata, firmware_path, enable_monitoring=True)
- return res
-
-
def client_get_or_generate_report_config(client):
GET_ALL_REPORT_CONFIGS = """
query {
diff --git a/landing_page/templates/dashboard.html b/landing_page/templates/dashboard.html
index cfb40196..9628c26d 100644
--- a/landing_page/templates/dashboard.html
+++ b/landing_page/templates/dashboard.html
@@ -61,14 +61,6 @@
Toolbox
E-Mail Policy Generator
Create DMARC and/or SPF policies which help you to enhance your e-mail security!
-
-
-
-
-
-
IOT Firmware Testing
-
Check your IOT firmware binary!
-
diff --git a/onekey/__init__.py b/onekey/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/onekey/admin.py b/onekey/admin.py
deleted file mode 100644
index 3841c4b7..00000000
--- a/onekey/admin.py
+++ /dev/null
@@ -1,39 +0,0 @@
-from django.contrib import admin, messages
-
-from .helpers import api_login, client_upload_firmware, get_default_product_group
-from .models import FirmwareAnalysisRequest
-
-# Register your models here.
-
-
-@admin.register(FirmwareAnalysisRequest)
-class FirmwareAnalysisRequestAdmin(admin.ModelAdmin):
- actions = [
- "validate_status",
- "decline_status",
- "pending_status",
- ]
-
- @admin.action(description="Validate")
- def validate_status(self, request, queryset):
- for analysis_request in queryset:
- if not analysis_request.firmware_uuid:
- client = api_login()
- default_product_group = get_default_product_group(client)
- firmware = client_upload_firmware(
- client, analysis_request, default_product_group
- )
- firmware_uuid = firmware["id"]
- analysis_request.firmware_uuid = firmware_uuid
- analysis_request.status = True
- analysis_request.save()
- else:
- messages.error(request, "This request was already made.")
-
- @admin.action(description="Decline")
- def decline_status(self, request, queryset):
- queryset.update(status=False)
-
- @admin.action(description="Set to pending")
- def pending_status(self, request, queryset):
- queryset.update(status=None)
diff --git a/onekey/apps.py b/onekey/apps.py
deleted file mode 100644
index a36b4f87..00000000
--- a/onekey/apps.py
+++ /dev/null
@@ -1,6 +0,0 @@
-from django.apps import AppConfig
-
-
-class OnekeyConfig(AppConfig):
- default_auto_field = "django.db.models.BigAutoField"
- name = "onekey"
diff --git a/onekey/forms.py b/onekey/forms.py
deleted file mode 100644
index dc8f85e6..00000000
--- a/onekey/forms.py
+++ /dev/null
@@ -1,19 +0,0 @@
-from django import forms
-
-from .models import FirmwareAnalysisRequest
-
-
-class FirmwareAnalysisRequestForm(forms.ModelForm):
- class Meta:
- model = FirmwareAnalysisRequest
- fields = [
- "firmware_name",
- "firmware_vendor_name",
- "firmware_product_name",
- "firmware_file",
- ]
-
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
- for visible in self.visible_fields():
- visible.field.widget.attrs["class"] = "form_control"
diff --git a/onekey/helpers.py b/onekey/helpers.py
deleted file mode 100644
index 520795bb..00000000
--- a/onekey/helpers.py
+++ /dev/null
@@ -1,198 +0,0 @@
-import json
-import secrets
-from pathlib import Path
-
-import jwt
-import requests
-from decouple import config
-from django.core.files.storage import FileSystemStorage
-from django.core.signing import Signer
-from onekey_client import Client, FirmwareMetadata
-
-from testing_platform import settings
-
-
-def api_login():
- client = Client(api_url=settings.ONEKEY_API_URL)
- signer = Signer()
- try:
- client.login(settings.ONEKEY_API_EMAIL, settings.ONEKEY_API_PASSWORD)
- tenant = client.get_tenant("Luxembourg House of Cybersecurity")
- client.use_tenant(tenant)
- except Exception as e:
- raise e
- return client
-
-
-def get_default_product_group(client):
- GET_PRODUCT_GROUPS = """
- query {
- allProductGroups {
- id
- name
- }
- }
- """
- res = client.query(GET_PRODUCT_GROUPS)
- default_product_group = next(
- pg for pg in res["allProductGroups"] if pg["name"] == "Default"
- )
- return default_product_group
-
-
-def client_upload_firmware(client, firmware_analysis_request, default_product_group):
- metadata = FirmwareMetadata(
- name=firmware_analysis_request.firmware_name,
- vendor_name=firmware_analysis_request.firmware_vendor_name,
- product_name=firmware_analysis_request.firmware_product_name,
- product_group_id=default_product_group["id"],
- )
- firmware_path = Path(firmware_analysis_request.firmware_file.path)
- res = client.upload_firmware(metadata, firmware_path, enable_monitoring=True)
- return res
-
-
-def client_get_or_generate_report_config(client):
- GET_ALL_REPORT_CONFIGS = """
- query {
- allReportConfigurations { id, name }
- }
- """
- GENERATE_REPORT_CONFIG = """
- mutation {
- createReportConfiguration(input: {
- name: "TP Report",
- issueSeverities: [CRITICAL, HIGH, MEDIUM, INFORMATIONAL, LOW],
- complianceGuidelineIds: ["f3463279-0234-46d0-9f02-68c941b8b107",
- "d74e4b79-7613-4e13-bc20-d88f3bfe6b4b",
- "9f09232a-f66b-4046-9f2a-3ca44e776deb",
- "af2c4a04-42bd-437b-9982-e98e46dddc30",
- "6956638d-428f-44d0-85c7-459c1544436c",
- "45f2094e-904b-47c8-8042-0964b1d09f7e"],
- analysisTechniqueDetails: true,
- includeComments: true
- }) {
- ... on ReportConfiguration {
- id,
- }
- ...on MutationError {
- count
- errors {
- message
- code
- ...on ValidationError {
- fieldPath
- }
- }
- }
- }
- }
- """
- res = client.query(GET_ALL_REPORT_CONFIGS)
- print(res)
- try:
- report_config = next(
- cfg for cfg in res["allReportConfigurations"] if cfg["name"] == "TP Report"
- )
- except StopIteration:
- report_config = None
- if report_config:
- return report_config
- else:
- client.query(GENERATE_REPORT_CONFIG)
- res = client.query(GET_ALL_REPORT_CONFIGS)
- print(res)
- report_config = next(
- cfg for cfg in res["allReportConfigurations"] if cfg["name"] == "TP Report"
- )
- return report_config
-
-
-def client_generate_report(client, firmware_uuid, report_title):
- report_config = client_get_or_generate_report_config(client)
- report_config = report_config["id"]
- GENERATE_REPORT = """
- mutation M {{
- generateReport(input: {{
- reportConfigurationId: "{}",
- firmwareIds: [
- "{}"
- ],
- title: "{}",
-
- }}) {{
- ... on Report {{
- id,
- title,
- generatedTime,
- downloadUrl,
- size,
-
- }}
- ... on MutationError {{
- count
- errors {{
- message
- code
- ... on ValidationError {{
- fieldPath
- }}
- }}
- }}
- }}
- }}
- """.format(
- report_config, firmware_uuid, report_title
- )
- res = client.query(GENERATE_REPORT)
- report = res["generateReport"]
- print(report)
- return report
-
-
-def client_request_link(client, report_uuid):
- GENERATE_REPORT_LINK = """
- mutation M {{
- createReportLink (input: {{
- reportId: "{}",
- validity: 86400
- }}) {{
- ... on CreatedReportLink {{
- downloadUrl
- id
- validUntil
- }}
- ... on MutationError {{
- count
- errors {{
- message
- code
- fieldPath
- }}
- }}
- }}
- }}
- """.format(
- report_uuid
- )
- res = client.query(GENERATE_REPORT_LINK)
- return res["createReportLink"]
-
-
-def client_get_all_reports_states(client, analysis_requests):
- GET_ALL_REPORTS = """
- query {
- allReports { id, state }
- }
- """
- res = client.query(GET_ALL_REPORTS)
- states = []
- for req in analysis_requests:
- if req.report_uuid:
- state = next(
- rep for rep in res["allReports"] if rep["id"] == str(req.report_uuid)
- )["state"]
- else:
- state = "Pending"
- states.append(state.capitalize())
- return zip(analysis_requests, states)
diff --git a/onekey/migrations/0001_initial.py b/onekey/migrations/0001_initial.py
deleted file mode 100644
index cd132d17..00000000
--- a/onekey/migrations/0001_initial.py
+++ /dev/null
@@ -1,54 +0,0 @@
-# Generated by Django 4.2.3 on 2023-10-05 07:58
-
-import django.db.models.deletion
-from django.conf import settings
-from django.db import migrations, models
-
-import onekey.models
-
-
-class Migration(migrations.Migration):
- initial = True
-
- dependencies = [
- migrations.swappable_dependency(settings.AUTH_USER_MODEL),
- ]
-
- operations = [
- migrations.CreateModel(
- name="FirmwareAnalysisRequest",
- fields=[
- (
- "id",
- models.BigAutoField(
- auto_created=True,
- primary_key=True,
- serialize=False,
- verbose_name="ID",
- ),
- ),
- ("request_nb", models.CharField(max_length=12)),
- ("firmware_name", models.CharField(max_length=200)),
- ("firmware_vendor_name", models.CharField(max_length=200)),
- ("firmware_product_name", models.CharField(max_length=200)),
- (
- "firmware_file",
- models.FileField(upload_to=onekey.models.get_upload_path),
- ),
- (
- "firmware_uuid",
- models.UUIDField(blank=True, default=None, null=True),
- ),
- ("status", models.BooleanField(blank=True, default=None, null=True)),
- ("report_uuid", models.UUIDField(blank=True, default=None, null=True)),
- ("report_link", models.URLField(blank=True, default=None, null=True)),
- (
- "user",
- models.ForeignKey(
- on_delete=django.db.models.deletion.CASCADE,
- to=settings.AUTH_USER_MODEL,
- ),
- ),
- ],
- ),
- ]
diff --git a/onekey/migrations/__init__.py b/onekey/migrations/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/onekey/models.py b/onekey/models.py
deleted file mode 100644
index 885f6aeb..00000000
--- a/onekey/models.py
+++ /dev/null
@@ -1,61 +0,0 @@
-import datetime
-import os
-
-from django.db import models
-
-from authentication.models import User
-
-
-def get_upload_path(instance, filename):
- return f"user_{instance.user.id}/{filename}"
-
-
-class FirmwareAnalysisRequest(models.Model):
- user = models.ForeignKey(User, on_delete=models.CASCADE)
- request_nb = models.CharField(max_length=12)
- firmware_name = models.CharField(max_length=200, blank=False, null=False)
- firmware_vendor_name = models.CharField(max_length=200, blank=False, null=False)
- firmware_product_name = models.CharField(max_length=200, blank=False, null=False)
- firmware_file = models.FileField(upload_to=get_upload_path)
- firmware_uuid = models.UUIDField(default=None, blank=True, null=True)
- status = models.BooleanField(default=None, blank=True, null=True)
- report_uuid = models.UUIDField(default=None, blank=True, null=True)
- report_link = models.URLField(default=None, blank=True, null=True)
-
- @property
- def filename(self):
- return os.path.basename(self.firmware_file.name)
-
- def status_prop(self):
- if self.status is False:
- alert = "Declined"
- elif self.status is None:
- alert = "Pending"
- else:
- alert = "Validated"
- return alert
-
- status_field = property(status_prop)
-
- def __str__(self):
- return f"Request {self.request_nb}"
-
- def save(self, *args, **kwargs):
- request_date = datetime.date.today()
- if not self.request_nb:
- try:
- request_id = int(
- FirmwareAnalysisRequest.objects.order_by("id").last().request_nb
- )
- if request_id:
- self.request_nb = request_id + 1
- else:
- pass
- except Exception:
- request_id = 1
- self.request_nb = (
- f'{request_date.year}{request_date.month}{(2-len(str(request_date.day)))*"0"}'
- f'{request_date.day}{(3-len(str(request_id)))*"0"}{request_id}'
- )
-
- super().save(*args, **kwargs)
diff --git a/onekey/templates/onekey_index.html b/onekey/templates/onekey_index.html
deleted file mode 100644
index d4a4906e..00000000
--- a/onekey/templates/onekey_index.html
+++ /dev/null
@@ -1,80 +0,0 @@
-{% extends "base.html" %}
-{% load i18n static %}
-{% block content %}
-
-
-
-
-
-
- ONEKEY IoT firmware analysis
-
-
Test the firmware of your IoT devices against modern norms, recommendations and guidelines.
-
-
- In order to design proper security controls adapted to your specific environment, you need to know
- what are the intrinsic vulnerabilities of the IoT devices you are using. To do so, we have
- partnered with ONEKEY GmbH whose solution is particularly advanced and comprehensive,
- and generates detailed firmware analysis reports.
-
-
-
-
-
-
-
- Here you can upload firmware images from your IoT devices to have them analyzed and receive a
- detailed report of the found vulnerabilities, compliance with major IoT standards, and more.
-
-
-
-
-
-
-
My ongoing requests
-
- {% if requests %}
-
-
- Request number
- Request name
- Request status
- Firmware UUID
- Report status
- Link to the report
-
- {% for request, status in requests %}
-
- {{ request.request_nb }}
- {{ request.firmware_name }}
- {{ request.status_field }}
- {{ request.firmware_uuid }}
- {{ status }}
- {% if status == "Finished" and request.report_link %}
- Download report
- {% elif not request.report_uuid %}
- No report available yet. Generate a report
- {% elif status == "Finished" and not request.report_link %}
- Report available. Generate a download link
- {% elif status == "Generating" %}
- Report is generating
- {% endif %}
-
- {% endfor %}
-
- {% else %}
-
No request registered
- {% endif %}
-
-
-
-
-
-
-
-{% endblock %}
diff --git a/onekey/templates/onekey_request.html b/onekey/templates/onekey_request.html
deleted file mode 100644
index c729995a..00000000
--- a/onekey/templates/onekey_request.html
+++ /dev/null
@@ -1,55 +0,0 @@
-{% extends "base.html" %}
-{% load i18n static %}
-{% block content %}
-
-
-
-
-
-
- ONEKEY IoT firmware analysis
-
-
Test the firmware of your IoT devices against modern norms, recommendations and guidelines.
-
-
- In order to design proper security controls adapted to your specific environment, you need to know
- what are the intrinsic vulnerabilities of the IoT devices you are using. To do so, we have
- partnered with ONEKEY GmbH whose solution is particularly advanced and comprehensive,
- and generates detailed firmware analysis reports.
-
-
-
-
-
-
-
-
Request Firmware Analysis
-
-
-
-
-
-{% endblock %}
diff --git a/onekey/tests.py b/onekey/tests.py
deleted file mode 100644
index 7ce503c2..00000000
--- a/onekey/tests.py
+++ /dev/null
@@ -1,3 +0,0 @@
-from django.test import TestCase
-
-# Create your tests here.
diff --git a/onekey/urls.py b/onekey/urls.py
deleted file mode 100644
index 25ec8a18..00000000
--- a/onekey/urls.py
+++ /dev/null
@@ -1,19 +0,0 @@
-from django.urls import path
-
-from . import views
-
-urlpatterns = [
- path("", views.index, name="iot_index"),
- path("request/", views.analysis_request, name="analysis_request"),
- path(
- "generate_report/firmware=",
- views.generate_report,
- name="generate_report",
- ),
- path(
- "generate_link/report=", views.generate_link, name="generate_link"
- ),
- path(
- "download/report=", views.download_report, name="download_report"
- ),
-]
diff --git a/onekey/views.py b/onekey/views.py
deleted file mode 100644
index 367d0209..00000000
--- a/onekey/views.py
+++ /dev/null
@@ -1,80 +0,0 @@
-from django.contrib import messages
-from django.contrib.auth.decorators import login_required
-from django.http import FileResponse, HttpResponse
-from django.shortcuts import redirect, render
-
-from .forms import FirmwareAnalysisRequestForm
-from .helpers import api_login, client_generate_report, client_request_link, client_get_all_reports_states
-from .models import FirmwareAnalysisRequest
-
-
-# Create your views here.
-@login_required
-def index(request):
- client = api_login()
- reqs = FirmwareAnalysisRequest.objects.filter(user=request.user.id)
- reqs_status = client_get_all_reports_states(client, reqs)
- context = {"requests": reqs_status}
- return render(request, "onekey_index.html", context=context)
-
-
-def analysis_request(request):
- if request.method == "POST":
- form = FirmwareAnalysisRequestForm(request.POST, request.FILES)
- if form.is_valid():
- data = form.cleaned_data
- firmware_analysis_request = FirmwareAnalysisRequest(
- user=request.user,
- firmware_name=data["firmware_name"],
- firmware_vendor_name=data["firmware_vendor_name"],
- firmware_product_name=data["firmware_product_name"],
- firmware_file=data["firmware_file"],
- )
- firmware_analysis_request.save()
- messages.success(
- request,
- "Your analysis request was successfully saved, you will receive a pricing offer"
- " in the next few days.",
- )
- return redirect("iot_index")
- else:
- form = FirmwareAnalysisRequestForm()
- return render(request, "onekey_request.html", {"form": form})
-
-
-def generate_report(request, firmware_uuid):
- firmware_analysis_request = FirmwareAnalysisRequest.objects.get(
- firmware_uuid=firmware_uuid
- )
- client = api_login()
- request = client_generate_report(
- client, firmware_uuid, str(firmware_analysis_request.request_nb)
- )
- firmware_analysis_request.report_uuid = request["id"]
- firmware_analysis_request.save()
- return redirect("iot_index")
-
-
-def generate_link(request, report_uuid):
- firmware_analysis_request = FirmwareAnalysisRequest.objects.get(
- report_uuid=report_uuid
- )
- client = api_login()
- res = client_request_link(client, report_uuid)
- firmware_analysis_request.report_link = res["downloadUrl"]
- firmware_analysis_request.save()
- return redirect("iot_index")
-
-
-def download_report(request, report_uuid):
- firmware_analysis_request = FirmwareAnalysisRequest.objects.get(
- report_uuid=report_uuid
- )
- link = firmware_analysis_request.report_link
- firmware_analysis_request.report_link = None
- firmware_analysis_request.save()
- return redirect(link)
-
-
-def test(request):
- return redirect("https://stackoverflow.com")
diff --git a/pyproject.toml b/pyproject.toml
index c1e618a6..9903781b 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -33,7 +33,6 @@ croniter = ">=1.0.15,<1.1.0"
imap-tools = "^0.57.0"
xmltodict = "^0.13.0"
ipwhois = "^1.2.0"
-onekey-client = "^2.0.2"
psutil = "^5.9.4"
certifi = "^2023.7.22"
django-enumfields = "^2.1.1"
diff --git a/requirements.txt b/requirements.txt
index 097a9a94..f89ea6e9 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -499,9 +499,6 @@ numpy==1.26.4 ; python_version >= "3.9" and python_version <= "3.11" or python_v
--hash=sha256:edd8b5fe47dab091176d21bb6de568acdd906d1887a4584a15a9a96a1dca06ef \
--hash=sha256:f870204a840a60da0b12273ef34f7051e98c3b5961b61b0c2c1be6dfd64fbcd3 \
--hash=sha256:ffa75af20b44f8dba823498024771d5ac50620e6915abac414251bd971b4529f
-onekey-client==2.2.0 ; python_version >= "3.9" and python_version < "4.0" \
- --hash=sha256:35bc3a2ff2b90764076fc5e8a2002fed55ab5b4a62e7d025d617eb77f4925a4b \
- --hash=sha256:625a471fed7abc736d14825bcabfafc7806c7f92875c62f0e1e7a714fc1857fb
pandas==2.2.1 ; python_version >= "3.9" and python_version < "4.0" \
--hash=sha256:04f6ec3baec203c13e3f8b139fb0f9f86cd8c0b94603ae3ae8ce9a422e9f5bee \
--hash=sha256:06cf591dbaefb6da9de8472535b185cba556d0ce2e6ed28e21d919704fef1a9e \
diff --git a/testing_platform/settings.py b/testing_platform/settings.py
index 1357b7c6..5525da8b 100644
--- a/testing_platform/settings.py
+++ b/testing_platform/settings.py
@@ -68,7 +68,6 @@
"authentication",
"testing",
"iot_inspector",
- "onekey",
"automation",
"contact",
"c3_protocols",
@@ -227,10 +226,6 @@
IOT_API_EMAIL = os.environ.get("IOT_API_EMAIL", "")
IOT_API_PASSWORD = os.environ.get("IOT_API_PASSWORD", "")
-ONEKEY_API_URL = "https://app.eu.onekey.com/api"
-ONEKEY_API_EMAIL = os.environ.get("ONEKEY_API_EMAIL", "")
-ONEKEY_API_PASSWORD = os.environ.get("ONEKEY_API_PASSWORD", "")
-
DMARC_API_KEY = os.environ.get("DMARC_API_KEY", "")
LOGGING = {
diff --git a/testing_platform/urls.py b/testing_platform/urls.py
index 2b87a71b..1333ba58 100644
--- a/testing_platform/urls.py
+++ b/testing_platform/urls.py
@@ -27,7 +27,6 @@
path("infra-testing/", include("testing.urls")),
path("c3-protocols/", include("c3_protocols.urls")),
path("specialized-testing/", include("specialized_testing.urls")),
- path("iot-testing/", include("onekey.urls")),
path("admin/", admin.site.urls),
path("contact/", include("contact.urls")),
path("kb/", include("knowledge_base.urls")),