From 01a0d07151bf12cad45905f1ba717de6441363e4 Mon Sep 17 00:00:00 2001 From: Sophia Dao Date: Sun, 7 Jul 2024 09:50:48 -0500 Subject: [PATCH 1/3] chore: clean-up repo --- Dockerfile | 11 - README.md | 38 ---- be_poc/api/__init__.py | 0 be_poc/api/admin.py | 6 - be_poc/api/apps.py | 6 - be_poc/api/fixtures/dummy_accounts.json | 203 ------------------ be_poc/api/migrations/0001_initial.py | 65 ------ ..._groups_cloudaccount_resources_and_more.py | 54 ----- ...003_alter_audit_aws_account_id_and_more.py | 24 --- ...move_account_billing_cancel_at_and_more.py | 97 --------- ...oudaccount_alias_cloudaccount_connected.py | 23 -- be_poc/api/migrations/__init__.py | 0 be_poc/api/models.py | 57 ----- be_poc/api/serializers.py | 31 --- be_poc/api/tests.py | 3 - be_poc/api/urls_v1.py | 8 - be_poc/api/views.py | 27 --- be_poc/be_poc/__init__.py | 0 be_poc/be_poc/asgi.py | 7 - be_poc/be_poc/settings.py | 119 ---------- be_poc/be_poc/urls.py | 7 - be_poc/be_poc/wsgi.py | 7 - be_poc/manage.py | 22 -- docker-compose.yaml | 7 - 24 files changed, 822 deletions(-) delete mode 100644 Dockerfile delete mode 100644 be_poc/api/__init__.py delete mode 100644 be_poc/api/admin.py delete mode 100644 be_poc/api/apps.py delete mode 100644 be_poc/api/fixtures/dummy_accounts.json delete mode 100644 be_poc/api/migrations/0001_initial.py delete mode 100644 be_poc/api/migrations/0002_cloudaccount_groups_cloudaccount_resources_and_more.py delete mode 100644 be_poc/api/migrations/0003_alter_audit_aws_account_id_and_more.py delete mode 100644 be_poc/api/migrations/0004_remove_account_billing_cancel_at_and_more.py delete mode 100644 be_poc/api/migrations/0005_cloudaccount_alias_cloudaccount_connected.py delete mode 100644 be_poc/api/migrations/__init__.py delete mode 100644 be_poc/api/models.py delete mode 100644 be_poc/api/serializers.py delete mode 100644 be_poc/api/tests.py delete mode 100644 be_poc/api/urls_v1.py delete mode 100644 be_poc/api/views.py delete mode 100644 be_poc/be_poc/__init__.py delete mode 100644 be_poc/be_poc/asgi.py delete mode 100644 be_poc/be_poc/settings.py delete mode 100644 be_poc/be_poc/urls.py delete mode 100644 be_poc/be_poc/wsgi.py delete mode 100755 be_poc/manage.py delete mode 100644 docker-compose.yaml diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 2b280ad451..0000000000 --- a/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM python:3.11.9-slim - -COPY requirements.txt /requirements.txt -COPY be_poc /be_poc - -RUN python -m pip install -r /requirements.txt -WORKDIR /be_poc -RUN python manage.py migrate && \ - python manage.py loaddata dummy_accounts - -ENTRYPOINT ["python", "manage.py", "runserver", "0.0.0.0:8000"] diff --git a/README.md b/README.md index 1843bf36d7..08df0a9c7c 100644 --- a/README.md +++ b/README.md @@ -51,41 +51,3 @@ After modifying the `.npmrc` file, you need to run `pnpm install` again to ensur ## License Licensed under the [MIT license](https://github.com/nextui-org/next-app-template/blob/main/LICENSE). - -# Prowler Django REST API (PoC) - -## Requirements - -- Have `docker` and `docker compose` installed. - -## How to run the REST API - -### Build the service image - -``` -docker compose build django-be-poc -``` - -### Start the service - -``` -docker compose up django-be-poc -``` - -## API - -The API will be accessible through HTTP, port `8080`. For instance, `http://localhost:8080/api/v1/`. - -### Implemented endpoints for the PoC: - -``` -/api/v1/providers/{provider_id}/accounts (the only available provider is 'aws') -``` - -### Expected response with `curl` - -```shellsession -curl http://localhost:8080/api/v1/providers/aws/accounts - -[{"id":1,"type":"Cloudy","enable":true,"provider_id":"aws","provider_data":{"test":"test value"},"inserted_at":"2024-06-24T10:20:18.309000Z","updated_at":"2024-06-24T10:20:18.309000Z","connected":true,"last_checked_at":"2024-06-24T10:20:04Z","alias":"dummy_alias","scanner_configuration":{"full_scan":true},"account_id":1}]% -``` diff --git a/be_poc/api/__init__.py b/be_poc/api/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/be_poc/api/admin.py b/be_poc/api/admin.py deleted file mode 100644 index 1132d5e64b..0000000000 --- a/be_poc/api/admin.py +++ /dev/null @@ -1,6 +0,0 @@ -from django.contrib import admin -from .models import Account, CloudAccount, Audit - -admin.site.register(Account) -admin.site.register(CloudAccount) -admin.site.register(Audit) diff --git a/be_poc/api/apps.py b/be_poc/api/apps.py deleted file mode 100644 index 66656fd29b..0000000000 --- a/be_poc/api/apps.py +++ /dev/null @@ -1,6 +0,0 @@ -from django.apps import AppConfig - - -class ApiConfig(AppConfig): - default_auto_field = 'django.db.models.BigAutoField' - name = 'api' diff --git a/be_poc/api/fixtures/dummy_accounts.json b/be_poc/api/fixtures/dummy_accounts.json deleted file mode 100644 index bc4b04401d..0000000000 --- a/be_poc/api/fixtures/dummy_accounts.json +++ /dev/null @@ -1,203 +0,0 @@ -[ - { - "model": "api.account", - "pk": "c0bbdcd2-c69e-4bdf-bea7-8db6524fd205", - "fields": { - "name": "prod", - "inserted_at": "2024-06-25T09:03:20.273Z", - "updated_at": "2024-06-25T09:03:20.273Z", - "aws_account_id": "232136659152", - "scan_window_start_at": "2024-06-29T09:03:17Z" - } - }, - { - "model": "api.account", - "pk": "cf51b7a0-687e-4a2a-bf3d-14f98dcb4c3f", - "fields": { - "name": "platform", - "inserted_at": "2024-06-25T09:03:08.847Z", - "updated_at": "2024-06-25T09:03:08.847Z", - "aws_account_id": "714274078102", - "scan_window_start_at": "2024-06-28T09:03:08Z" - } - }, - { - "model": "api.account", - "pk": "cf9d2400-9a10-4c7b-a3be-6215c41b619e", - "fields": { - "name": "dev", - "inserted_at": "2024-06-25T09:02:34.188Z", - "updated_at": "2024-06-25T09:02:34.188Z", - "aws_account_id": "106908755756", - "scan_window_start_at": "2024-06-29T09:02:27Z" - } - }, - { - "model": "api.account", - "pk": "dbc452bd-b51c-4199-8b42-c1bc8164d45d", - "fields": { - "name": "marketplace", - "inserted_at": "2024-06-25T09:02:58.412Z", - "updated_at": "2024-06-25T09:02:58.412Z", - "aws_account_id": "879304169158", - "scan_window_start_at": "2024-06-27T09:02:57Z" - } - }, - { - "model": "api.account", - "pk": "fabc5b58-901b-4ba6-9901-4b2349acf492", - "fields": { - "name": "management", - "inserted_at": "2024-06-25T09:02:46.950Z", - "updated_at": "2024-06-25T09:02:46.950Z", - "aws_account_id": "741399645537", - "scan_window_start_at": "2024-06-27T09:02:46Z" - } - }, - { - "model": "api.cloudaccount", - "pk": "1f1dd221-6d49-4413-a8b7-e10ca4b0660a", - "fields": { - "account_id": "cf9d2400-9a10-4c7b-a3be-6215c41b619e", - "type": "test", - "groups": [ - "Operation" - ], - "resources": 644, - "enable": true, - "provider_id": "aws", - "inserted_at": "2024-06-25T09:03:57.233Z", - "updated_at": "2024-06-25T09:03:57.233Z", - "alias": "dev", - "connected": true - } - }, - { - "model": "api.cloudaccount", - "pk": "4997b2eb-a9f9-4d12-800b-1a6394728510", - "fields": { - "account_id": "c0bbdcd2-c69e-4bdf-bea7-8db6524fd205", - "type": "test", - "groups": [ - "Production" - ], - "resources": 564, - "enable": true, - "provider_id": "aws", - "inserted_at": "2024-06-25T09:04:56.941Z", - "updated_at": "2024-06-25T09:04:56.941Z", - "alias": "prod", - "connected": true - } - }, - { - "model": "api.cloudaccount", - "pk": "668bb77d-cfb4-4f4a-8c51-45beb16af4e9", - "fields": { - "account_id": "dbc452bd-b51c-4199-8b42-c1bc8164d45d", - "type": "test", - "groups": [ - "Production" - ], - "resources": 148, - "enable": true, - "provider_id": "aws", - "inserted_at": "2024-06-25T09:04:31.753Z", - "updated_at": "2024-06-25T09:04:31.753Z", - "alias": "marketplace", - "connected": true - } - }, - { - "model": "api.cloudaccount", - "pk": "a50d3d9d-ac2d-47d1-ac6c-29c8d304072e", - "fields": { - "account_id": "fabc5b58-901b-4ba6-9901-4b2349acf492", - "type": "test", - "groups": [ - "Production", - "Operation" - ], - "resources": 356, - "enable": true, - "provider_id": "aws", - "inserted_at": "2024-06-25T09:04:14.567Z", - "updated_at": "2024-06-25T09:04:14.567Z", - "alias": "management", - "connected": true - } - }, - { - "model": "api.cloudaccount", - "pk": "d71c8ac6-074d-45a3-a7a7-0595ab5440bc", - "fields": { - "account_id": "cf51b7a0-687e-4a2a-bf3d-14f98dcb4c3f", - "type": "test", - "groups": [ - "Production" - ], - "resources": 112, - "enable": true, - "provider_id": "aws", - "inserted_at": "2024-06-25T09:04:44.431Z", - "updated_at": "2024-06-25T09:04:44.431Z", - "alias": "platform", - "connected": true - } - }, - { - "model": "api.audit", - "pk": "0f712e8e-b419-40b4-9d85-65ef723fc1b9", - "fields": { - "aws_account_id": "fabc5b58-901b-4ba6-9901-4b2349acf492", - "audit_complete": true, - "inserted_at": "2024-06-25T09:05:37.352Z", - "updated_at": "2024-06-25T09:05:37.352Z", - "audit_duration": "00:06:30" - } - }, - { - "model": "api.audit", - "pk": "1bf18315-34e6-4912-8e8e-3e4650e4653e", - "fields": { - "aws_account_id": "dbc452bd-b51c-4199-8b42-c1bc8164d45d", - "audit_complete": true, - "inserted_at": "2024-06-25T09:05:43.601Z", - "updated_at": "2024-06-25T09:05:43.601Z", - "audit_duration": "00:08:00" - } - }, - { - "model": "api.audit", - "pk": "48605239-58ee-4dbf-8a46-3ef42b270a19", - "fields": { - "aws_account_id": "cf9d2400-9a10-4c7b-a3be-6215c41b619e", - "audit_complete": true, - "inserted_at": "2024-06-25T09:05:29.533Z", - "updated_at": "2024-06-25T09:05:29.533Z", - "audit_duration": "00:06:12" - } - }, - { - "model": "api.audit", - "pk": "955c1a4f-496a-4df5-96c8-578280b7a914", - "fields": { - "aws_account_id": "cf51b7a0-687e-4a2a-bf3d-14f98dcb4c3f", - "audit_complete": true, - "inserted_at": "2024-06-25T09:05:49.405Z", - "updated_at": "2024-06-25T09:05:49.405Z", - "audit_duration": "00:06:40" - } - }, - { - "model": "api.audit", - "pk": "ccbedd87-d64e-42dd-86d0-15ac60ade56d", - "fields": { - "aws_account_id": "c0bbdcd2-c69e-4bdf-bea7-8db6524fd205", - "audit_complete": true, - "inserted_at": "2024-06-25T09:06:00.463Z", - "updated_at": "2024-06-25T09:06:00.463Z", - "audit_duration": "00:07:12" - } - } -] diff --git a/be_poc/api/migrations/0001_initial.py b/be_poc/api/migrations/0001_initial.py deleted file mode 100644 index 5960d1d738..0000000000 --- a/be_poc/api/migrations/0001_initial.py +++ /dev/null @@ -1,65 +0,0 @@ -# Generated by Django 5.0.6 on 2024-06-24 10:11 - -import django.db.models.deletion -from django.db import migrations, models - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - ] - - operations = [ - migrations.CreateModel( - name='Account', - fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=255)), - ('token', models.CharField(max_length=255)), - ('inserted_at', models.DateTimeField(auto_now_add=True)), - ('updated_at', models.DateTimeField(auto_now=True)), - ('card_brand', models.CharField(max_length=255)), - ('card_exp_month', models.IntegerField()), - ('card_exp_year', models.IntegerField()), - ('card_last4', models.CharField(max_length=4)), - ('onboarding_required', models.BooleanField()), - ('onboarding_step', models.CharField(max_length=255)), - ('onboarding_completed_at', models.DateTimeField()), - ('aws_account_id', models.CharField(max_length=255)), - ('off_boarded', models.BooleanField()), - ('billing_type', models.CharField(max_length=255)), - ('billing_cancel_at', models.DateTimeField()), - ('billing_current_period_end_at', models.DateTimeField()), - ('billing_free_resource_count', models.IntegerField()), - ('grafana_org_name', models.CharField(max_length=255)), - ('billing_email', models.CharField(max_length=255)), - ('scan_window_start_at', models.DateTimeField()), - ('company_name', models.CharField(max_length=255)), - ], - options={ - 'db_table': 'accounts', - }, - ), - migrations.CreateModel( - name='CloudAccount', - fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('type', models.CharField(max_length=255)), - ('enable', models.BooleanField()), - ('provider_id', models.CharField(max_length=255)), - ('provider_data', models.JSONField()), - ('inserted_at', models.DateTimeField(auto_now_add=True)), - ('updated_at', models.DateTimeField(auto_now=True)), - ('connected', models.BooleanField()), - ('last_checked_at', models.DateTimeField()), - ('alias', models.CharField(max_length=255)), - ('scanner_configuration', models.JSONField()), - ('account_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.account')), - ], - options={ - 'db_table': 'cloud_accounts', - }, - ), - ] diff --git a/be_poc/api/migrations/0002_cloudaccount_groups_cloudaccount_resources_and_more.py b/be_poc/api/migrations/0002_cloudaccount_groups_cloudaccount_resources_and_more.py deleted file mode 100644 index 20586a6a14..0000000000 --- a/be_poc/api/migrations/0002_cloudaccount_groups_cloudaccount_resources_and_more.py +++ /dev/null @@ -1,54 +0,0 @@ -# Generated by Django 5.0.6 on 2024-06-25 08:56 - -import django.db.models.deletion -import uuid -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('api', '0001_initial'), - ] - - operations = [ - migrations.AddField( - model_name='cloudaccount', - name='groups', - field=models.JSONField(default=list), - ), - migrations.AddField( - model_name='cloudaccount', - name='resources', - field=models.IntegerField(default=0), - ), - migrations.AlterField( - model_name='account', - name='id', - field=models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False), - ), - migrations.AlterField( - model_name='cloudaccount', - name='account_id', - field=models.ForeignKey(db_column='account_id', on_delete=django.db.models.deletion.CASCADE, to='api.account', unique=True), - ), - migrations.AlterField( - model_name='cloudaccount', - name='id', - field=models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False), - ), - migrations.CreateModel( - name='Audit', - fields=[ - ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), - ('audit_complete', models.BooleanField(default=True)), - ('inserted_at', models.DateTimeField(auto_now_add=True)), - ('updated_at', models.DateTimeField(auto_now=True)), - ('audit_duration', models.DurationField()), - ('aws_account_id', models.ForeignKey(db_column='aws_account_id', on_delete=django.db.models.deletion.CASCADE, to='api.cloudaccount', to_field='account_id', unique=True)), - ], - options={ - 'db_table': 'audits', - }, - ), - ] diff --git a/be_poc/api/migrations/0003_alter_audit_aws_account_id_and_more.py b/be_poc/api/migrations/0003_alter_audit_aws_account_id_and_more.py deleted file mode 100644 index 971d1370b6..0000000000 --- a/be_poc/api/migrations/0003_alter_audit_aws_account_id_and_more.py +++ /dev/null @@ -1,24 +0,0 @@ -# Generated by Django 5.0.6 on 2024-06-25 08:57 - -import django.db.models.deletion -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('api', '0002_cloudaccount_groups_cloudaccount_resources_and_more'), - ] - - operations = [ - migrations.AlterField( - model_name='audit', - name='aws_account_id', - field=models.OneToOneField(db_column='aws_account_id', on_delete=django.db.models.deletion.CASCADE, to='api.cloudaccount', to_field='account_id'), - ), - migrations.AlterField( - model_name='cloudaccount', - name='account_id', - field=models.OneToOneField(db_column='account_id', on_delete=django.db.models.deletion.CASCADE, to='api.account'), - ), - ] diff --git a/be_poc/api/migrations/0004_remove_account_billing_cancel_at_and_more.py b/be_poc/api/migrations/0004_remove_account_billing_cancel_at_and_more.py deleted file mode 100644 index 89ad02512d..0000000000 --- a/be_poc/api/migrations/0004_remove_account_billing_cancel_at_and_more.py +++ /dev/null @@ -1,97 +0,0 @@ -# Generated by Django 5.0.6 on 2024-06-25 09:01 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('api', '0003_alter_audit_aws_account_id_and_more'), - ] - - operations = [ - migrations.RemoveField( - model_name='account', - name='billing_cancel_at', - ), - migrations.RemoveField( - model_name='account', - name='billing_current_period_end_at', - ), - migrations.RemoveField( - model_name='account', - name='billing_email', - ), - migrations.RemoveField( - model_name='account', - name='billing_free_resource_count', - ), - migrations.RemoveField( - model_name='account', - name='billing_type', - ), - migrations.RemoveField( - model_name='account', - name='card_brand', - ), - migrations.RemoveField( - model_name='account', - name='card_exp_month', - ), - migrations.RemoveField( - model_name='account', - name='card_exp_year', - ), - migrations.RemoveField( - model_name='account', - name='card_last4', - ), - migrations.RemoveField( - model_name='account', - name='company_name', - ), - migrations.RemoveField( - model_name='account', - name='grafana_org_name', - ), - migrations.RemoveField( - model_name='account', - name='off_boarded', - ), - migrations.RemoveField( - model_name='account', - name='onboarding_completed_at', - ), - migrations.RemoveField( - model_name='account', - name='onboarding_required', - ), - migrations.RemoveField( - model_name='account', - name='onboarding_step', - ), - migrations.RemoveField( - model_name='account', - name='token', - ), - migrations.RemoveField( - model_name='cloudaccount', - name='alias', - ), - migrations.RemoveField( - model_name='cloudaccount', - name='connected', - ), - migrations.RemoveField( - model_name='cloudaccount', - name='last_checked_at', - ), - migrations.RemoveField( - model_name='cloudaccount', - name='provider_data', - ), - migrations.RemoveField( - model_name='cloudaccount', - name='scanner_configuration', - ), - ] diff --git a/be_poc/api/migrations/0005_cloudaccount_alias_cloudaccount_connected.py b/be_poc/api/migrations/0005_cloudaccount_alias_cloudaccount_connected.py deleted file mode 100644 index 9edec907e3..0000000000 --- a/be_poc/api/migrations/0005_cloudaccount_alias_cloudaccount_connected.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by Django 4.2.13 on 2024-06-26 07:56 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('api', '0004_remove_account_billing_cancel_at_and_more'), - ] - - operations = [ - migrations.AddField( - model_name='cloudaccount', - name='alias', - field=models.CharField(max_length=255, null=True), - ), - migrations.AddField( - model_name='cloudaccount', - name='connected', - field=models.BooleanField(default=False), - ), - ] diff --git a/be_poc/api/migrations/__init__.py b/be_poc/api/migrations/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/be_poc/api/models.py b/be_poc/api/models.py deleted file mode 100644 index 067c24b0d5..0000000000 --- a/be_poc/api/models.py +++ /dev/null @@ -1,57 +0,0 @@ -import uuid - -from django.db import models - - -class Account(models.Model): - class Meta: - db_table = "accounts" - - id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) - name = models.CharField(max_length=255) - inserted_at = models.DateTimeField(auto_now_add=True) - updated_at = models.DateTimeField(auto_now=True) - aws_account_id = models.CharField(max_length=255) - scan_window_start_at = models.DateTimeField() - - def __str__(self): - return f"{self.name} - {self.id}" - - -class CloudAccount(models.Model): - class Meta: - db_table = "cloud_accounts" - - id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) - account_id = models.OneToOneField( - Account, on_delete=models.CASCADE, db_column="account_id", to_field="id" - ) - type = models.CharField(max_length=255) - groups = models.JSONField(default=list) - resources = models.IntegerField(default=0) - enable = models.BooleanField() - alias = models.CharField(max_length=255, null=True) - connected = models.BooleanField(default=False) - provider_id = models.CharField(max_length=255) - inserted_at = models.DateTimeField(auto_now_add=True) - updated_at = models.DateTimeField(auto_now=True) - - def __str__(self): - return f"{self.id} ({self.provider_id})" - - -class Audit(models.Model): - class Meta: - db_table = "audits" - - id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) - aws_account_id = models.OneToOneField( - CloudAccount, on_delete=models.CASCADE, db_column="aws_account_id", to_field="account_id" - ) - audit_complete = models.BooleanField(default=True) - inserted_at = models.DateTimeField(auto_now_add=True) - updated_at = models.DateTimeField(auto_now=True) - audit_duration = models.DurationField() - - def __str__(self): - return f"{self.id} - {self.aws_account_id}" diff --git a/be_poc/api/serializers.py b/be_poc/api/serializers.py deleted file mode 100644 index 171a69a73c..0000000000 --- a/be_poc/api/serializers.py +++ /dev/null @@ -1,31 +0,0 @@ -from rest_framework import serializers -from .models import Account, CloudAccount, Audit - - -class AccountSerializer(serializers.ModelSerializer): - class Meta: - model = Account - fields = "__all__" - - -class CloudAccountSerializer(serializers.ModelSerializer): - aws_account_id = serializers.SerializerMethodField() - - class Meta: - model = CloudAccount - fields = "__all__" - extra_fields = ["aws_account_id"] - - def get_aws_account_id(self, obj): - return obj.account_id.aws_account_id - - -class AuditSerializer(serializers.ModelSerializer): - account_id = serializers.SerializerMethodField() - - class Meta: - model = Audit - fields = ['id', 'audit_complete', 'inserted_at', 'updated_at', 'audit_duration', 'account_id'] - - def get_account_id(self, obj): - return obj.aws_account_id.account_id.id diff --git a/be_poc/api/tests.py b/be_poc/api/tests.py deleted file mode 100644 index 7ce503c2dd..0000000000 --- a/be_poc/api/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/be_poc/api/urls_v1.py b/be_poc/api/urls_v1.py deleted file mode 100644 index 9386c301dc..0000000000 --- a/be_poc/api/urls_v1.py +++ /dev/null @@ -1,8 +0,0 @@ -from django.urls import path - -from .views import AuditListView, CloudAccountListView - -urlpatterns = [ - path('providers//accounts', CloudAccountListView.as_view(), name='cloud-account-list'), - path('providers/aws/audits', AuditListView.as_view(), name='aws-audit-list'), -] diff --git a/be_poc/api/views.py b/be_poc/api/views.py deleted file mode 100644 index ebbddb1450..0000000000 --- a/be_poc/api/views.py +++ /dev/null @@ -1,27 +0,0 @@ -from rest_framework import generics -from .models import Account, CloudAccount, Audit -from .serializers import AccountSerializer, CloudAccountSerializer, AuditSerializer - - -class AccountListView(generics.ListAPIView): - queryset = Account.objects.all() - serializer_class = AccountSerializer - - -class CloudAccountListView(generics.ListAPIView): - serializer_class = CloudAccountSerializer - - def get_queryset(self): - provider_id = self.kwargs.get('provider_id') - return CloudAccount.objects.filter(provider_id=provider_id) - - -class AuditListView(generics.ListAPIView): - serializer_class = AuditSerializer - - def get_queryset(self): - queryset = Audit.objects.all() - account_id = self.request.query_params.get('account_id') - if account_id: - queryset = queryset.filter(aws_account_id__account_id=account_id) - return queryset diff --git a/be_poc/be_poc/__init__.py b/be_poc/be_poc/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/be_poc/be_poc/asgi.py b/be_poc/be_poc/asgi.py deleted file mode 100644 index 2b8704ac78..0000000000 --- a/be_poc/be_poc/asgi.py +++ /dev/null @@ -1,7 +0,0 @@ -import os - -from django.core.asgi import get_asgi_application - -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'be_poc.settings') - -application = get_asgi_application() diff --git a/be_poc/be_poc/settings.py b/be_poc/be_poc/settings.py deleted file mode 100644 index f6fb8e2fee..0000000000 --- a/be_poc/be_poc/settings.py +++ /dev/null @@ -1,119 +0,0 @@ -from pathlib import Path - -# Build paths inside the project like this: BASE_DIR / 'subdir'. -BASE_DIR = Path(__file__).resolve().parent.parent - - -# Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/ - -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'django-insecure-h72a3mgf$l$1uqnjf0bbbz9fbmuotlff7ya50+hlao)fga=3dp' - -# SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True - -ALLOWED_HOSTS = ['localhost', 'steady-separately-marlin.ngrok-free.app'] - - -# Application definition - -INSTALLED_APPS = [ - 'django.contrib.admin', - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.messages', - 'django.contrib.staticfiles', - - 'rest_framework', - 'api', - 'corsheaders', -] - -MIDDLEWARE = [ - 'django.middleware.security.SecurityMiddleware', - 'django.contrib.sessions.middleware.SessionMiddleware', - 'django.middleware.common.CommonMiddleware', - 'django.middleware.csrf.CsrfViewMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', - 'django.middleware.clickjacking.XFrameOptionsMiddleware', - - 'corsheaders.middleware.CorsMiddleware' -] - -CORS_ALLOW_ALL_ORIGINS = True - -ROOT_URLCONF = 'be_poc.urls' - -TEMPLATES = [ - { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [], - 'APP_DIRS': True, - 'OPTIONS': { - 'context_processors': [ - 'django.template.context_processors.debug', - 'django.template.context_processors.request', - 'django.contrib.auth.context_processors.auth', - 'django.contrib.messages.context_processors.messages', - ], - }, - }, -] - -WSGI_APPLICATION = 'be_poc.wsgi.application' - - -# Database -# https://docs.djangoproject.com/en/5.0/ref/settings/#databases - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': BASE_DIR / 'db.sqlite3', - } -} - - -# Password validation -# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators - -AUTH_PASSWORD_VALIDATORS = [ - { - 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', - }, - { - 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', - }, - { - 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', - }, - { - 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', - }, -] - - -# Internationalization -# https://docs.djangoproject.com/en/5.0/topics/i18n/ - -LANGUAGE_CODE = 'en-us' - -TIME_ZONE = 'UTC' - -USE_I18N = True - -USE_TZ = True - - -# Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/5.0/howto/static-files/ - -STATIC_URL = 'static/' - -# Default primary key field type -# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field - -DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' diff --git a/be_poc/be_poc/urls.py b/be_poc/be_poc/urls.py deleted file mode 100644 index 8c12f37f20..0000000000 --- a/be_poc/be_poc/urls.py +++ /dev/null @@ -1,7 +0,0 @@ -from django.contrib import admin -from django.urls import path, include - -urlpatterns = [ - path('admin/', admin.site.urls), - path('api/v1/', include('api.urls_v1')), -] diff --git a/be_poc/be_poc/wsgi.py b/be_poc/be_poc/wsgi.py deleted file mode 100644 index 0a66b5cc5e..0000000000 --- a/be_poc/be_poc/wsgi.py +++ /dev/null @@ -1,7 +0,0 @@ -import os - -from django.core.wsgi import get_wsgi_application - -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'be_poc.settings') - -application = get_wsgi_application() diff --git a/be_poc/manage.py b/be_poc/manage.py deleted file mode 100755 index b07263b7cb..0000000000 --- a/be_poc/manage.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python -"""Django's command-line utility for administrative tasks.""" -import os -import sys - - -def main(): - """Run administrative tasks.""" - os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'be_poc.settings') - try: - from django.core.management import execute_from_command_line - except ImportError as exc: - raise ImportError( - "Couldn't import Django. Are you sure it's installed and " - "available on your PYTHONPATH environment variable? Did you " - "forget to activate a virtual environment?" - ) from exc - execute_from_command_line(sys.argv) - - -if __name__ == '__main__': - main() diff --git a/docker-compose.yaml b/docker-compose.yaml deleted file mode 100644 index 745691a46c..0000000000 --- a/docker-compose.yaml +++ /dev/null @@ -1,7 +0,0 @@ -services: - django-be-poc: - image: django-be-poc - build: - context: "./" - ports: - - "8080:8000" From 721aea945aaff53f17f06da216a9ecde190fed8c Mon Sep 17 00:00:00 2001 From: Sophia Dao Date: Sun, 7 Jul 2024 09:56:54 -0500 Subject: [PATCH 2/3] chore: clean up due to linter rules --- app/about/layout.tsx | 10 +--- app/blog/layout.tsx | 10 +--- app/clouds/layout.tsx | 6 +-- app/clouds/page.tsx | 53 ++++++++------------- app/docs/layout.tsx | 10 +--- app/error.tsx | 8 +--- app/layout.tsx | 28 ++++------- app/login/layout.tsx | 10 +--- app/login/page.tsx | 25 ++-------- app/page.tsx | 25 ++-------- app/pricing/layout.tsx | 10 +--- app/providers.tsx | 2 +- components/counter.tsx | 2 +- components/icons.tsx | 95 +++++-------------------------------- components/navbar.tsx | 12 ++--- components/primitives.ts | 10 +--- components/theme-switch.tsx | 34 ++++--------- 17 files changed, 78 insertions(+), 272 deletions(-) diff --git a/app/about/layout.tsx b/app/about/layout.tsx index 98956a52ad..cfdc03b801 100644 --- a/app/about/layout.tsx +++ b/app/about/layout.tsx @@ -1,13 +1,7 @@ -export default function AboutLayout({ - children, -}: { - children: React.ReactNode; -}) { +export default function AboutLayout({ children }: { children: React.ReactNode }) { return (
-
- {children} -
+
{children}
); } diff --git a/app/blog/layout.tsx b/app/blog/layout.tsx index 911d0bcf41..365caee773 100644 --- a/app/blog/layout.tsx +++ b/app/blog/layout.tsx @@ -1,13 +1,7 @@ -export default function BlogLayout({ - children, -}: { - children: React.ReactNode; -}) { +export default function BlogLayout({ children }: { children: React.ReactNode }) { return (
-
- {children} -
+
{children}
); } diff --git a/app/clouds/layout.tsx b/app/clouds/layout.tsx index d9ca1e80e4..8c8daab55d 100644 --- a/app/clouds/layout.tsx +++ b/app/clouds/layout.tsx @@ -1,8 +1,4 @@ -export default function CloudsLayout({ - children, -}: { - children: React.ReactNode; -}) { +export default function CloudsLayout({ children }: { children: React.ReactNode }) { return (
{children}
diff --git a/app/clouds/page.tsx b/app/clouds/page.tsx index a6f35d6e16..48d18551f8 100644 --- a/app/clouds/page.tsx +++ b/app/clouds/page.tsx @@ -1,43 +1,34 @@ "use client"; -import useSWR from "swr"; -import React from "react"; - +// import { PencilSquareIcon } from "@heroicons/react/24/solid"; +// import { TrashIcon } from "@heroicons/react/24/solid"; +// import { EyeIcon } from "@heroicons/react/24/solid"; import { + // Chip, + // getKeyValue, Table, - TableHeader, TableBody, - TableColumn, - TableRow, TableCell, - User, - Chip, - Tooltip, - getKeyValue, + TableColumn, + TableHeader, + TableRow, + // Tooltip, + // User, } from "@nextui-org/react"; -import { fetcher } from "@/utils/fetcher"; -import { title } from "@/components/primitives"; +import React from "react"; +import useSWR from "swr"; -import { PencilSquareIcon } from "@heroicons/react/24/solid"; -import { TrashIcon } from "@heroicons/react/24/solid"; -import { EyeIcon } from "@heroicons/react/24/solid"; +import { title } from "@/components/primitives"; +import { fetcher } from "@/utils/fetcher"; export default function CloudsPage() { - const getAccounts = useSWR( - `http://localhost:8080/api/v1/providers/aws/accounts`, - fetcher, - ); + const getAccounts = useSWR("http://localhost:8080/api/v1/providers/aws/accounts", fetcher); - const getAudits = useSWR( - `http://localhost:8080/api/v1/providers/aws/audits`, - fetcher, - ); + const getAudits = useSWR("http://localhost:8080/api/v1/providers/aws/audits", fetcher); // TODO FIX TYPE CHECKING - const getScanDetails = (account_id: Number, detail: String) => { - const scan = - getAudits.data && - getAudits.data.find((audit: any) => audit.account_id === account_id); + const getScanDetails = (account_id: number, detail: string) => { + const scan = getAudits.data && getAudits.data.find((audit: any) => audit.account_id === account_id); if (detail === "status") { return scan?.audit_complete && "Completed"; @@ -79,12 +70,8 @@ export default function CloudsPage() {

Cloud Accounts

- {getAccounts.error && ( - Failed to load - )} - {getAccounts.isLoading && ( - Loading - )} + {getAccounts.error && Failed to load} + {getAccounts.isLoading && Loading}

{getAccounts.data && ( diff --git a/app/docs/layout.tsx b/app/docs/layout.tsx index eaf63f3b99..e3d89f490a 100644 --- a/app/docs/layout.tsx +++ b/app/docs/layout.tsx @@ -1,13 +1,7 @@ -export default function DocsLayout({ - children, -}: { - children: React.ReactNode; -}) { +export default function DocsLayout({ children }: { children: React.ReactNode }) { return (
-
- {children} -
+
{children}
); } diff --git a/app/error.tsx b/app/error.tsx index 9ed5104e8a..388b7fcc7b 100644 --- a/app/error.tsx +++ b/app/error.tsx @@ -2,13 +2,7 @@ import { useEffect } from "react"; -export default function Error({ - error, - reset, -}: { - error: Error; - reset: () => void; -}) { +export default function Error({ error, reset }: { error: Error; reset: () => void }) { useEffect(() => { // Log the error to an error reporting service /* eslint-disable no-console */ diff --git a/app/layout.tsx b/app/layout.tsx index d81ea47ba9..39517f2bf1 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -1,10 +1,11 @@ -import { Metadata, Viewport } from "next"; -import clsx from "clsx"; - import "@/styles/globals.css"; -import { siteConfig } from "@/config/site"; -import { fontSans } from "@/config/fonts"; + +import clsx from "clsx"; +import { Metadata, Viewport } from "next"; + import { Navbar } from "@/components/navbar"; +import { fontSans } from "@/config/fonts"; +import { siteConfig } from "@/config/site"; import { Providers } from "./providers"; @@ -26,26 +27,15 @@ export const viewport: Viewport = { ], }; -export default function RootLayout({ - children, -}: { - children: React.ReactNode; -}) { +export default function RootLayout({ children }: { children: React.ReactNode }) { return ( - +
-
- {children} -
+
{children}
diff --git a/app/login/layout.tsx b/app/login/layout.tsx index d3a4a58ea4..561d6bcc49 100644 --- a/app/login/layout.tsx +++ b/app/login/layout.tsx @@ -1,13 +1,7 @@ -export default function LoginLayout({ - children, -}: { - children: React.ReactNode; -}) { +export default function LoginLayout({ children }: { children: React.ReactNode }) { return (
-
- {children} -
+
{children}
); } diff --git a/app/login/page.tsx b/app/login/page.tsx index 113f81418e..c348917daf 100644 --- a/app/login/page.tsx +++ b/app/login/page.tsx @@ -1,17 +1,9 @@ "use client"; -import React from "react"; -import { - Card, - CardHeader, - CardBody, - CardFooter, - Input, - Link, - Button, -} from "@nextui-org/react"; import { EyeIcon } from "@heroicons/react/24/solid"; import { EyeSlashIcon } from "@heroicons/react/24/solid"; +import { Button, Card, CardBody, CardFooter, CardHeader, Input, Link } from "@nextui-org/react"; +import React from "react"; export default function LoginPage() { const [isVisible, setIsVisible] = React.useState(false); @@ -26,22 +18,13 @@ export default function LoginPage() {

Login

- + +