Skip to content

Commit

Permalink
Merge pull request #719 from cisagov/718-remove-readysetcyber-python-…
Browse files Browse the repository at this point in the history
…code

Remove ReadySetCyber from Python Backend.
  • Loading branch information
Matthew-Grayson authored Nov 14, 2024
2 parents 764e04f + 0fe8b53 commit a572a2d
Show file tree
Hide file tree
Showing 8 changed files with 1 addition and 276 deletions.
118 changes: 0 additions & 118 deletions backend/src/xfd_django/xfd_api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,48 +35,6 @@ class Meta:
db_table = "api_key"


class Assessment(models.Model):
"""The Assessment model."""

id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
createdAt = models.DateTimeField(auto_now_add=True, db_column="createdAt")
updatedAt = models.DateTimeField(auto_now=True, db_column="updatedAt")
rscId = models.CharField(max_length=255, db_column="rscId", unique=True)
type = models.CharField(max_length=255)

user = models.ForeignKey(
"User",
db_column="userId",
blank=True,
null=True,
on_delete=models.CASCADE,
related_name="assessments",
)

class Meta:
"""The Meta class for Assessment."""

managed = False
db_table = "assessment"


class Category(models.Model):
"""The Category model."""

id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
name = models.CharField(max_length=255)
number = models.CharField(max_length=255, unique=True)
shortName = models.CharField(
db_column="shortName", max_length=255, blank=True, null=True
)

class Meta:
"""The Meta class for Category model."""

managed = False
db_table = "category"


class Cpe(models.Model):
"""The Cpe model."""

Expand Down Expand Up @@ -371,81 +329,6 @@ class Meta:
db_table = "query-result-cache"


class Question(models.Model):
"""The Question model."""

id = models.UUIDField(primary_key=True)
name = models.CharField(max_length=255)
description = models.CharField(blank=True, null=True)
longForm = models.CharField(db_column="longForm")
number = models.CharField(max_length=255)
categoryId = models.ForeignKey(
Category, models.DO_NOTHING, db_column="categoryId", blank=True, null=True
)

class Meta:
"""The Meta class for Question."""

db_table = "question"
managed = False
unique_together = (("category", "number"),)


# Question and Resource many-to-many
class QuestionResourcesResource(models.Model):
"""The QuestionResourcesResource model."""

questionId = models.ForeignKey(
"Question", on_delete=models.CASCADE, db_column="questionId"
)
resourceId = models.ForeignKey(
"Resource", on_delete=models.CASCADE, db_column="resourceId"
)

class Meta:
"""The Meta class for QuestionResourcesResource."""

db_table = "question_resources_resource"
managed = False
unique_together = (("question", "resource"),)


class Resource(models.Model):
"""The Resource model."""

id = models.UUIDField(primary_key=True)
description = models.CharField()
name = models.CharField()
type = models.CharField()
url = models.CharField(unique=True)

class Meta:
"""The Meta class for Resource."""

managed = False
db_table = "resource"


class Response(models.Model):
"""The Response model."""

id = models.UUIDField(primary_key=True)
selection = models.CharField()
assessmentId = models.ForeignKey(
Assessment, models.DO_NOTHING, db_column="assessmentId", blank=True, null=True
)
questionId = models.ForeignKey(
Question, models.DO_NOTHING, db_column="questionId", blank=True, null=True
)

class Meta:
"""The Meta class for Resource."""

managed = False
db_table = "response"
unique_together = (("assessmentId", "questionId"),)


class Role(models.Model):
"""The Role model."""

Expand Down Expand Up @@ -657,7 +540,6 @@ class UserType(models.TextChoices):
GLOBAL_ADMIN = "globalAdmin"
GLOBAL_VIEW = "globalView"
REGIONAL_ADMIN = "regionalAdmin"
READY_SET_CYBER = "readySetCyber"
STANDARD = "standard"


Expand Down
24 changes: 0 additions & 24 deletions backend/src/xfd_django/xfd_api/schema_models/assessment.py

This file was deleted.

21 changes: 0 additions & 21 deletions backend/src/xfd_django/xfd_api/schema_models/category.py

This file was deleted.

23 changes: 0 additions & 23 deletions backend/src/xfd_django/xfd_api/schema_models/question.py

This file was deleted.

21 changes: 0 additions & 21 deletions backend/src/xfd_django/xfd_api/schema_models/resource.py

This file was deleted.

21 changes: 0 additions & 21 deletions backend/src/xfd_django/xfd_api/schema_models/response.py

This file was deleted.

6 changes: 0 additions & 6 deletions backend/src/xfd_django/xfd_api/schema_models/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,6 @@ class GenericMessageResponseModel(BaseModel):
global_scan=False,
description="Creates domains from root domains by doing a single DNS lookup for each root domain.",
),
"rscSync": ScanSchema(
type="fargate",
isPassive=True,
global_scan=True,
description="Retrieves and saves assessments from ReadySetCyber mission instance.",
),
"savedSearch": ScanSchema(
type="fargate",
isPassive=True,
Expand Down
43 changes: 1 addition & 42 deletions backend/src/xfd_django/xfd_api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
)
from .auth import get_current_active_user
from .login_gov import callback, login
from .models import Assessment, User
from .models import User
from .schema_models import organization as OrganizationSchema
from .schema_models import scan as scanSchema
from .schema_models import scan_tasks as scanTaskSchema
Expand Down Expand Up @@ -126,47 +126,6 @@ async def pe_proxy(
return await proxy.proxy_request(request, os.getenv("PE_API_URL", ""), path)


# ========================================
# Assessment Endpoints
# ========================================


# TODO: Uncomment checks for current_user once authentication is implemented
@api_router.get(
"/assessments",
# current_user: User = Depends(get_current_active_user),
tags=["ReadySetCyber"],
)
async def list_assessments():
"""
Lists all assessments for the logged-in user.
Args:
current_user (User): The current authenticated user.
Raises:
HTTPException: If the user is not authorized or assessments are not found.
Returns:
List[Assessment]: A list of assessments for the logged-in user.
"""
# Ensure the user is authenticated
# if not current_user:
# raise HTTPException(status_code=401, detail="Unauthorized")

# Query the database for assessments belonging to the current user
# assessments = Assessment.objects.filter(user=current_user)
assessments = (
Assessment.objects.all()
) # TODO: Remove this line once filtering by user is implemented

# Return assessments if found, or raise a 404 error if none exist
if not assessments.exists():
raise HTTPException(status_code=404, detail="No assessments found")

return list(assessments)


@api_router.get(
"/cpes/{cpe_id}",
# dependencies=[Depends(get_current_active_user)],
Expand Down

0 comments on commit a572a2d

Please sign in to comment.