-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pytest run doctests Edit Actor model , Edit create_git_repo and view function
- Loading branch information
Showing
12 changed files
with
261 additions
and
149 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -136,3 +136,4 @@ | |
|
||
MEDIA_URL = "/media/" | ||
MEDIA_ROOT = os.path.join(BASE_DIR, "media") | ||
GIT_PATH = os.path.join(MEDIA_ROOT, "git") |
This file contains 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
This file contains 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
Empty file.
This file contains 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 import forms | ||
|
||
|
||
class CreateRepoForm(forms.Form): | ||
repo_name = forms.CharField() | ||
repo_url = forms.URLField(required=True) |
This file contains 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 |
---|---|---|
@@ -1,33 +1,29 @@ | ||
# Generated by Django 4.2.2 on 2023-06-26 13:44 | ||
# Generated by Django 4.2.2 on 2023-06-29 08:43 | ||
|
||
from django.conf import settings | ||
import django.contrib.auth.models | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import uuid | ||
|
||
import django.db.models.deletion | ||
from django.conf import settings | ||
from django.db import migrations | ||
from django.db import models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
("auth", "0012_alter_user_first_name_max_length"), | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="DatabaseAdmin", | ||
fields=[ | ||
( | ||
"user_ptr", | ||
models.OneToOneField( | ||
auto_created=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
parent_link=True, | ||
primary_key=True, | ||
serialize=False, | ||
to=settings.AUTH_USER_MODEL, | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, primary_key=True, serialize=False, verbose_name="ID" | ||
), | ||
), | ||
( | ||
|
@@ -40,16 +36,24 @@ class Migration(migrations.Migration): | |
), | ||
("note", models.CharField(help_text="the profile description", max_length=100)), | ||
("public_key", models.TextField()), | ||
("followers", models.JSONField(default=dict)), | ||
( | ||
"followers", | ||
models.JSONField( | ||
default=dict, | ||
help_text="e.g. {'secrityteam@vcio': ['pkg:npm/[email protected]']}", | ||
), | ||
), | ||
("followers_count", models.PositiveIntegerField(default=0)), | ||
( | ||
"user", | ||
models.OneToOneField( | ||
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL | ||
), | ||
), | ||
], | ||
options={ | ||
"abstract": False, | ||
}, | ||
bases=("auth.user",), | ||
managers=[ | ||
("objects", django.contrib.auth.models.UserManager()), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name="GitRepo", | ||
|
@@ -108,23 +112,38 @@ class Migration(migrations.Migration): | |
auto_created=True, primary_key=True, serialize=False, verbose_name="ID" | ||
), | ||
), | ||
("voter_acct", models.CharField(help_text="security@vcio", max_length=100)), | ||
("gainer_acct", models.CharField(help_text="security@nexb", max_length=100)), | ||
("voter_acct", models.CharField(help_text="security@vcio.com", max_length=100)), | ||
("gainer_acct", models.CharField(help_text="security@nexb.com", max_length=100)), | ||
("positive", models.BooleanField(default=True)), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name="Vulnerability", | ||
fields=[ | ||
( | ||
"id", | ||
models.UUIDField( | ||
default=uuid.uuid4, editable=False, primary_key=True, serialize=False | ||
), | ||
), | ||
("branch_name", models.CharField(max_length=28)), | ||
("filename", models.CharField(max_length=255)), | ||
("commit_id", models.CharField(max_length=50)), | ||
( | ||
"git_repo", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, to="review.gitrepo" | ||
), | ||
), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name="SecurityTeam", | ||
fields=[ | ||
( | ||
"user_ptr", | ||
models.OneToOneField( | ||
auto_created=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
parent_link=True, | ||
primary_key=True, | ||
serialize=False, | ||
to=settings.AUTH_USER_MODEL, | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, primary_key=True, serialize=False, verbose_name="ID" | ||
), | ||
), | ||
( | ||
|
@@ -137,36 +156,23 @@ class Migration(migrations.Migration): | |
), | ||
("note", models.CharField(help_text="the profile description", max_length=100)), | ||
("public_key", models.TextField()), | ||
("following", models.JSONField(default=dict)), | ||
("following_count", models.PositiveIntegerField(default=0)), | ||
], | ||
options={ | ||
"abstract": False, | ||
}, | ||
bases=("auth.user",), | ||
managers=[ | ||
("objects", django.contrib.auth.models.UserManager()), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name="Vulnerability", | ||
fields=[ | ||
( | ||
"id", | ||
models.UUIDField( | ||
default=uuid.uuid4, editable=False, primary_key=True, serialize=False | ||
"following", | ||
models.JSONField( | ||
default=dict, help_text="e.g. {'datebase1@vcio': ['pkg:npm/[email protected]']}" | ||
), | ||
), | ||
("branch_name", models.CharField(max_length=28)), | ||
("filename", models.CharField(max_length=255)), | ||
("commit_id", models.CharField(max_length=50)), | ||
("following_count", models.PositiveIntegerField(default=0)), | ||
( | ||
"git_repo", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, to="review.gitrepo" | ||
"user", | ||
models.OneToOneField( | ||
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL | ||
), | ||
), | ||
], | ||
options={ | ||
"abstract": False, | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name="Review", | ||
|
@@ -177,6 +183,7 @@ class Migration(migrations.Migration): | |
auto_created=True, primary_key=True, serialize=False, verbose_name="ID" | ||
), | ||
), | ||
("headline", models.CharField(max_length=300)), | ||
("data", models.TextField()), | ||
( | ||
"status", | ||
|
@@ -185,7 +192,7 @@ class Migration(migrations.Migration): | |
), | ||
), | ||
( | ||
"author", | ||
"creator", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, to="review.securityteam" | ||
), | ||
|
This file contains 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 |
---|---|---|
|
@@ -6,16 +6,17 @@ | |
from purl_sync.settings import DOMAIN | ||
|
||
|
||
class Actor(User): | ||
avatar = models.ImageField(upload_to="uploads/", help_text="the profile image", default="favicon-16x16.png") | ||
class Actor(models.Model): | ||
avatar = models.ImageField( | ||
upload_to="uploads/", help_text="the profile image", default="favicon-16x16.png" | ||
) | ||
note = models.CharField(help_text="the profile description", max_length=100) | ||
public_key = models.TextField(blank=False) | ||
REQUIRED_FIELDS = ["username", "email", "password"] | ||
|
||
@property | ||
def acct(self): | ||
"""The Webfinger account URI""" | ||
return f"{self.username}@{DOMAIN}" | ||
return f"{self.user.username}@{DOMAIN}" | ||
|
||
@property | ||
def reputation_value(self): | ||
|
@@ -34,7 +35,10 @@ class Reputation(models.Model): | |
|
||
|
||
class DatabaseAdmin(Actor): | ||
followers = models.JSONField(default=dict, help_text="e.g. {'secrityteam@vcio': ['pkg:npm/[email protected]']}") | ||
user = models.OneToOneField(User, on_delete=models.CASCADE) | ||
followers = models.JSONField( | ||
default=dict, help_text="e.g. {'secrityteam@vcio': ['pkg:npm/[email protected]']}" | ||
) | ||
followers_count = models.PositiveIntegerField(default=0) | ||
|
||
def save(self, *args, **kwargs): | ||
|
@@ -64,7 +68,10 @@ class PackageUrl(models.Model): | |
|
||
|
||
class SecurityTeam(Actor): | ||
following = models.JSONField(default=dict, help_text="e.g. {'datebase1@vcio': ['pkg:npm/[email protected]']}") | ||
user = models.OneToOneField(User, on_delete=models.CASCADE) | ||
following = models.JSONField( | ||
default=dict, help_text="e.g. {'datebase1@vcio': ['pkg:npm/[email protected]']}" | ||
) | ||
following_count = models.PositiveIntegerField(default=0) | ||
|
||
def save(self, *args, **kwargs): | ||
|
@@ -81,8 +88,11 @@ class Notes(models.Model): | |
|
||
|
||
class Review(models.Model): | ||
author = models.ForeignKey(SecurityTeam, on_delete=models.CASCADE, help_text="") | ||
headline = models.CharField(max_length=300) | ||
creator = models.ForeignKey(SecurityTeam, on_delete=models.CASCADE, help_text="") | ||
|
||
git_repo = models.ForeignKey(GitRepo, on_delete=models.CASCADE, help_text="") | ||
|
||
data = models.TextField() | ||
notes = models.ManyToManyField(Notes) | ||
|
||
|
@@ -107,7 +117,7 @@ class Meta: | |
|
||
class RemoteSecurityTeam(RemoteActor): | ||
@property | ||
def get_data(self): | ||
def get_profile_data(self): | ||
raise NotImplementedError | ||
|
||
@property | ||
|
@@ -117,7 +127,7 @@ def create_activity(self): | |
|
||
class RemoteDatabaseAdmin(RemoteActor): | ||
@property | ||
def get_data(self): | ||
def get_profile_data(self): | ||
raise NotImplementedError | ||
|
||
@property | ||
|
This file contains 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,15 @@ | ||
{ | ||
"subject": "{{ resource }}", | ||
"links": [ | ||
{ | ||
"rel": "https://webfinger.net/rel/profile-page", | ||
"type": "text/html", | ||
"href": "https://{{ domain }}/{{ user_type }}/@{{ username }}" | ||
}, | ||
{ | ||
"rel": "self", | ||
"type": "application/activity+json", | ||
"href": "https://{{ domain }}/users/{{ user_type }}/{{ username }}" | ||
} | ||
] | ||
} |
Oops, something went wrong.