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

BLT Private Project #1737

Closed
wants to merge 66 commits into from
Closed
Show file tree
Hide file tree
Changes from 54 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
64310e4
anonynomus user can't view private issue
HanilJain Jan 23, 2024
2acf36a
Merge branch 'main' into issue-1685
HanilJain Jan 23, 2024
a44688d
anonymous user handling in API
HanilJain Jan 26, 2024
7d21c90
Merge branch 'issue-1685' of https://github.com/HanilJain/BLT into is…
HanilJain Jan 26, 2024
1ac233f
Merge branch 'OWASP:main' into issue-1685
HanilJain Jan 26, 2024
499f91a
Merge branch 'main' into issue-1685
HanilJain Jan 28, 2024
eb800bf
request access
HanilJain Jan 28, 2024
59ac12d
Merge branch 'OWASP:main' into issue-1090
HanilJain Jan 28, 2024
27883ba
changes
HanilJain Jan 29, 2024
0469a25
Merge branch 'main' into issue-1685
HanilJain Jan 29, 2024
3e2ac4b
automated test added for relevant api
HanilJain Jan 29, 2024
261c7a8
Merge branch 'OWASP:main' into issue-1090
HanilJain Jan 30, 2024
5dbcf35
request access email
HanilJain Jan 30, 2024
2d4b1c8
changes
HanilJain Jan 30, 2024
14dc376
Merge branch 'issue-1685' into issue-1090
HanilJain Jan 30, 2024
a9eb1d1
Merge branch 'main' into issue-1090
HanilJain Jan 31, 2024
fb06ef0
priavte bug feature
HanilJain Feb 3, 2024
758e2a8
Merge branch 'OWASP:main' into issue-1702
HanilJain Feb 3, 2024
6fdf101
commit
HanilJain Feb 3, 2024
980b359
Merge branch 'issue-1702' of https://github.com/HanilJain/BLT into is…
HanilJain Feb 3, 2024
0832dfe
Merge branch 'main' into issue-1702
HanilJain Feb 4, 2024
97e7c39
Merge branch 'main' into issue-1702
HanilJain Feb 5, 2024
6d10870
Merge branch 'main' into issue-1702
HanilJain Feb 8, 2024
24d0423
Merge branch 'main' into issue-1702
HanilJain Feb 9, 2024
264e6fd
Merge branch 'main' into issue-1702
HanilJain Feb 13, 2024
aa5adbe
Merge branch 'main' into issue-1702
HanilJain Feb 13, 2024
7823104
Merge branch 'main' into issue-1702
HanilJain Feb 14, 2024
116dbe9
Merge branch 'main' into issue-1702
HanilJain Feb 15, 2024
c0515e7
Merge branch 'main' into issue-1702
HanilJain Feb 15, 2024
c0453c9
Merge branch 'main' into issue-1702
HanilJain Feb 16, 2024
8aec6bd
changed urls
HanilJain Feb 16, 2024
e2db596
Merge branch 'issue-1702' of https://github.com/HanilJain/BLT into is…
HanilJain Feb 16, 2024
8577c4f
Merge branch 'main' into issue-1702
HanilJain Feb 17, 2024
08a92bc
Merge branch 'main' into issue-1702
HanilJain Feb 17, 2024
e0e395b
Merge branch 'main' into issue-1702
HanilJain Feb 17, 2024
e906e36
Merge branch 'main' into issue-1702
HanilJain Feb 17, 2024
9c2e1c4
Merge branch 'main' into issue-1702
HanilJain Feb 17, 2024
9c7a679
Merge branch 'OWASP:main' into issue-1702
HanilJain Feb 18, 2024
59b8c58
commit
HanilJain Feb 18, 2024
0046c96
Merge branch 'main' into issue-1702
HanilJain Feb 19, 2024
64b6f8a
Merge branch 'main' into issue-1702
AtmegaBuzz Feb 20, 2024
2d9b0ff
Merge branch 'main' into issue-1702
AtmegaBuzz Feb 21, 2024
117cc70
Merge branch 'main' into issue-1702
AtmegaBuzz Feb 21, 2024
cfa9126
Merge branch 'main' into issue-1702
HanilJain Feb 23, 2024
7758737
Merge branch 'main' into issue-1702
HanilJain Feb 23, 2024
79c67d6
changes made
HanilJain Feb 24, 2024
064db29
Merge branch 'issue-1702' of https://github.com/HanilJain/BLT into is…
HanilJain Feb 24, 2024
5c04f51
Merge branch 'main' into issue-1702
HanilJain Feb 25, 2024
0e6e712
Merge branch 'main' into issue-1702
HanilJain Feb 26, 2024
d8386c5
pre-commit
HanilJain Feb 26, 2024
3147550
pre_commit
HanilJain Feb 26, 2024
20789b4
run_test
HanilJain Feb 26, 2024
af32c56
suggested corrections
HanilJain Feb 27, 2024
558c42a
Merge branch 'main' into issue-1702
DonnieBLT Feb 28, 2024
f7b2d77
Merge branch 'main' into issue-1702
HanilJain Feb 28, 2024
c9975e5
flatten the rename migrations
HanilJain Feb 28, 2024
aa6fb12
pre_commit issues
HanilJain Feb 28, 2024
0594912
Merge branch 'main' into issue-1702
HanilJain Feb 28, 2024
cde7eda
Merge branch 'main' into issue-1702
HanilJain Feb 29, 2024
89444c7
Merge branch 'main' into issue-1702
HanilJain Feb 29, 2024
efc7460
Merge branch 'main' into issue-1702
HanilJain Mar 1, 2024
c6f0d77
Merge branch 'main' into issue-1702
HanilJain Mar 1, 2024
3e36387
Merge branch 'main' into issue-1702
HanilJain Mar 2, 2024
84db212
Merge branch 'main' into issue-1702
HanilJain Mar 2, 2024
c941772
Merge branch 'main' into issue-1702
HanilJain Mar 7, 2024
7e2081e
suggested changes
HanilJain Mar 7, 2024
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
19 changes: 18 additions & 1 deletion blt/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,24 @@
re_path(r"^contributors/$", contributors_view, name="contributors"),
path("company/", include("company.urls")),
path("sponsor/", website.views.sponsor_view, name="sponsor"),
path("companies/", DomainListView.as_view(), name="domain_lists"),

path(
"issue/<int:issue_pk>/request_access/",
website.views.request_access,
name="issue_request_access",
),
path(
"issue2/<int:issue_pk>/request_access/",
website.views.request_access,
name="issue_request_access",
),
path("private/<int:user_pk>/issue/", website.views.private_issue, name="private_issue"),
path(
"private/<int:user_pk>/issue/<int:issue_pk>/grant_access/",
website.views.grant_access,
name="grant_access",
),
path("companies/", DomainListView.as_view(), name="domain_list"),
]

if settings.DEBUG:
Expand Down
2 changes: 2 additions & 0 deletions website/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
IssueScreenshot,
Payment,
Points,
RequestIssueAccess,
Subscription,
UserProfile,
Wallet,
Expand Down Expand Up @@ -187,3 +188,4 @@ class UserAdmin(ImportExportModelAdmin):
admin.site.register(Payment, PaymentAdmin)
admin.site.register(IssueScreenshot)
admin.site.register(HuntPrize)
admin.site.register(RequestIssueAccess)
35 changes: 35 additions & 0 deletions website/decorator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from functools import wraps

from django.contrib import messages
from django.shortcuts import redirect

from website.models import Issue


def private_test_function(user, user_pk, issue_pk):
try:
issue = Issue.objects.get(id=issue_pk)
if user.pk == user_pk and issue.user.pk == user.pk:
return True

except:
HanilJain marked this conversation as resolved.
Show resolved Hide resolved
return user.pk == user_pk


def private_access_check(
message_to_deliver="Not allowed to \
access the Private page",
):
def decorator(view):
@wraps(view)
def _wrapped_view(request, *args, **kwargs):
pk = kwargs.get("user_pk")
issue_pk = kwargs.get("issue_pk")
if not private_test_function(request.user, pk, issue_pk):
messages.error(request, message_to_deliver)
return redirect("/accounts/login")
return view(request, *args, **kwargs)

return _wrapped_view

return decorator
48 changes: 48 additions & 0 deletions website/migrations/0082_requestaccess.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Generated by Django 4.2.8 on 2024-02-01 11:57

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("website", "0081_userprofile_issue_downvoted"),
]

operations = [
migrations.CreateModel(
name="RequestAccess",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("message", models.CharField(blank=True, max_length=100, null=True)),
(
"issue",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
to="website.issue",
),
),
(
"user",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL,
),
),
],
),
]
26 changes: 26 additions & 0 deletions website/migrations/0083_issue_viewer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 4.2.8 on 2024-02-02 17:52

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("website", "0082_requestaccess"),
]

operations = [
migrations.AddField(
model_name="issue",
name="viewer",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="viewer",
to=settings.AUTH_USER_MODEL,
),
),
]
28 changes: 28 additions & 0 deletions website/migrations/0084_remove_issue_viewer_issue_viewer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 4.2.8 on 2024-02-02 21:48

from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("website", "0083_issue_viewer"),
]

operations = [
migrations.RemoveField(
HanilJain marked this conversation as resolved.
Show resolved Hide resolved
model_name="issue",
name="viewer",
),
migrations.AddField(
model_name="issue",
name="viewer",
field=models.ManyToManyField(
blank=True,
null=True,
related_name="viewer",
to=settings.AUTH_USER_MODEL,
),
),
]
12 changes: 12 additions & 0 deletions website/migrations/0085_merge_20240218_1322.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Generated by Django 5.0.2 on 2024-02-18 13:22

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("website", "0082_issue_reporter_ip_address"),
("website", "0084_remove_issue_viewer_issue_viewer"),
]

operations = []
18 changes: 18 additions & 0 deletions website/migrations/0086_rename_requestaccess_requestissueaccess.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.0.2 on 2024-02-24 00:14

from django.conf import settings
from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("website", "0085_merge_20240218_1322"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.RenameModel(
old_name="RequestAccess",
new_name="RequestIssueAccess",
HanilJain marked this conversation as resolved.
Show resolved Hide resolved
),
]
12 changes: 12 additions & 0 deletions website/migrations/0087_merge_20240226_2025.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Generated by Django 5.0.2 on 2024-02-26 20:25

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("website", "0083_alter_invitefriend_options_and_more"),
("website", "0086_rename_requestaccess_requestissueaccess"),
]

operations = []
7 changes: 7 additions & 0 deletions website/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ class Issue(models.Model):
modified = models.DateTimeField(auto_now=True)
is_hidden = models.BooleanField(default=False)
rewarded = models.PositiveIntegerField(default=0) # money rewarded by the company
viewer = models.ManyToManyField(User, null=True, blank=True, related_name="viewer")
HanilJain marked this conversation as resolved.
Show resolved Hide resolved
reporter_ip_address = models.GenericIPAddressField(null=True, blank=True)

def __unicode__(self):
Expand Down Expand Up @@ -315,6 +316,12 @@ class Meta:
ordering = ["-created"]


class RequestIssueAccess(models.Model):
HanilJain marked this conversation as resolved.
Show resolved Hide resolved
issue = models.ForeignKey(Issue, null=True, blank=True, on_delete=models.CASCADE)
user = models.ForeignKey(User, null=True, blank=True, on_delete=models.CASCADE)
message = models.CharField(max_length=100, null=True, blank=True)


class IssueScreenshot(models.Model):
image = models.ImageField(upload_to="screenshots", validators=[validate_image])
issue = models.ForeignKey(Issue, on_delete=models.CASCADE, related_name="screenshots")
Expand Down
61 changes: 61 additions & 0 deletions website/templates/email/granted_access.txt
HanilJain marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{% load custom_tags %}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an HTML file, but labeled as.txt

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DonnieBLT It mail content which will sent after an access is granted

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body style="margin: 0; padding: 0;">
<table style="border: 1px solid #cccccc;" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>
<table align="center" border="0" cellpadding="0" cellspacing="0" width="600" style="border: 1px solid #cccccc;">
<tr>
<td align="center" style="padding: 40px 0 30px 0;">
<img src="https://{% env 'FQDN' %}/static/img/logo-large-transparent.png" alt="{% env 'PROJECT_NAME' %}" width="300" height="73" style="display: block;"/>
</td>
</tr>
<tr>
<td align="left">
Hey, {{name}},<br>
you have successfully granted viewership access of the following issue
https://{% env 'FQDN' %}/issue2/{{ issue_pk }}

Best,<br>
<br>
The {% env 'PROJECT_NAME' %} Team<br>
</td>
</tr>
<tr>
<td style="padding: 30px 30px 30px 30px;">
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="border: 1px solid #cccccc;">
<tr>
<td align="center">
<table border="0" cellpadding="0" cellspacing="0">
<tr border="0" align="center">
<td>
<a href="{% env 'TWITTER_URL' %}">
Twitter</a>
</td>
<td style="font-size: 0; line-height: 0;" width="20">&nbsp;</td>
<td>
<a href="{% env 'FACEBOOK_URL' %}">
Facebook</a>
</td>
<td style="font-size: 0; line-height: 0;" width="20">&nbsp;</td>
<td>
<a href="{% env 'GITHUB_URL' %}">
GitHub</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
61 changes: 61 additions & 0 deletions website/templates/email/request_access.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{% load custom_tags %}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body style="margin: 0; padding: 0;">
<table style="border: 1px solid #cccccc;" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>
<table align="center" border="0" cellpadding="0" cellspacing="0" width="600" style="border: 1px solid #cccccc;">
<tr>
<td align="center" style="padding: 40px 0 30px 0;">
<img src="https://{% env 'FQDN' %}/static/img/logo-large-transparent.png" alt="{% env 'PROJECT_NAME' %}" width="300" height="73" style="display: block;"/>
</td>
</tr>
<tr>
<td align="left">
Hey, {{name}},<br>
<a href="https://{% env 'FQDN' %}/profile/{{requester}}">{{ requester }}</a> has requested for the access of the following issue
https://{% env 'FQDN' %}/issue2/{{ issue_pk }}

Best,<br>
<br>
The {% env 'PROJECT_NAME' %} Team<br>
</td>
</tr>
<tr>
<td style="padding: 30px 30px 30px 30px;">
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="border: 1px solid #cccccc;">
<tr>
<td align="center">
<table border="0" cellpadding="0" cellspacing="0">
<tr border="0" align="center">
<td>
<a href="{% env 'TWITTER_URL' %}">
Twitter</a>
</td>
<td style="font-size: 0; line-height: 0;" width="20">&nbsp;</td>
<td>
<a href="{% env 'FACEBOOK_URL' %}">
Facebook</a>
</td>
<td style="font-size: 0; line-height: 0;" width="20">&nbsp;</td>
<td>
<a href="{% env 'GITHUB_URL' %}">
GitHub</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
Loading
Loading