Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions blt/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
SOCIAL_AUTH_GITHUB_SECRET = os.environ.get("GITHUB_CLIENT_SECRET", "blank")


MIDDLEWARE = (
MIDDLEWARE = [
"django.contrib.sessions.middleware.SessionMiddleware",
"blt.middleware.domain.DomainMiddleware",
"django.middleware.locale.LocaleMiddleware",
Expand All @@ -126,7 +126,7 @@
"tz_detect.middleware.TimezoneMiddleware",
"blt.middleware.ip_restrict.IPRestrictMiddleware",
"blt.middleware.user_visit_tracking.VisitTrackingMiddleware",
)
]

if DEBUG:
MIDDLEWARE += ["livereload.middleware.LiveReloadScript"]
Expand Down
863 changes: 567 additions & 296 deletions website/static/organization/js/hunt_controller.js

Large diffs are not rendered by default.

570 changes: 345 additions & 225 deletions website/templates/organization/bughunt/add_bughunt.html

Large diffs are not rendered by default.

782 changes: 496 additions & 286 deletions website/templates/organization/bughunt/edit_bughunt.html

Large diffs are not rendered by default.

354 changes: 253 additions & 101 deletions website/templates/organization/bughunt/organization_manage_bughunts.html

Large diffs are not rendered by default.

177 changes: 111 additions & 66 deletions website/templates/organization/dashboard/organization_manage_bugs.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,75 +16,120 @@
View and manage all bugs in your system. Easily filter, view, and update bug statuses to maintain efficient operations.
{% endblock og_description %}
{% block body %}
<div class="fixed bottom-2.5 right-3.75">
<a href="https://github.com/OWASP-BLT/BLT/blob/main/website/templates/organization/organization_manage_bugs.html">
<i class="fab fa-github"></i>
</a>
<a href="https://www.figma.com/file/s0xuxeU6O2guoWEfA9OElZ/Design?node-id=3%3A76&t=pqxWpF3hcYxjEDrs-1">
<i class="fab fa-figma"></i>
</a>
</div>
<div class="bg-[#F3F5F7] w-full h-full flex flex-col items-center">
<div class="flex items-center md:justify-between w-full md:h-max mt-5 flex-col md:flex-row">
<p class="text-red-700 font-satoshi font-bold text-[35px] px-8">Manage Bugs</p>
<div class="w-full md:w-[15%] flex justify-center md:justify-end mr-10">
<a href="{% url 'report' %}"
class="flex items-center justify-center md:justify-center px-16 py-7 bg-[#DC4654] rounded-xl hover:bg-red-600 transition-all">
<i class="fa-sharp fa-solid fa-plus fa-xl text-white"></i>
</a>
<div class="min-h-screen bg-gradient-to-br from-gray-50 to-gray-100">
<!-- Header Section -->
<div class="bg-white shadow-sm border-b border-gray-200">
<div class="mx-auto px-4 sm:px-6 lg:px-8 py-6">
<div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4">
<div>
<h1 class="text-3xl font-bold text-gray-900">Manage Bugs</h1>
<p class="mt-1 text-sm text-gray-500">Track and manage all reported security issues</p>
</div>
<a href="{% url 'report' %}"
class="inline-flex items-center px-4 py-2.5 bg-[#e74c3c] text-white rounded-xl font-medium hover:bg-red-700 transition-all duration-200 select-none">
<svg class="w-5 h-5 mr-2"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"></path>
</svg>
Report New Bug
</a>
</div>
</div>
</div>
<div class="w-[96%] h-[70vh] overflow-y-scroll flow-root my-10">
<div class="relative overflow-x-auto shadow-md sm:rounded-lg h-full bg-white">
<table class="w-full text-sm text-left text-gray-500">
<caption class="p-5 text-xl font-semibold text-left text-gray-900 bg-white">
<div class="flex w-full justify-between">
<h2 class="mt-1 text-xl font-extrabold text-gray-500">Bugs</h2>
</div>
</caption>
<thead class="text-gray-700 uppercase bg-gray-50">
<tr>
<th scope="col" class="px-6 py-3 text-[1rem]">Description</th>
<th scope="col" class="px-6 py-3 text-[1rem]">Created On</th>
<th scope="col" class="px-6 py-3 text-[1rem]">Bug Type</th>
<th scope="col" class="px-6 py-3 text-[1rem]">Status</th>
<th scope="col" class="px-6 py-3 text-[1rem]">
<span class="sr-only">View</span>
</th>
</tr>
</thead>
<tbody>
{% if issues %}
{% for issue in issues %}
<tr class="bg-white border-b hover:bg-gray-50 transition-colors">
<th scope="row"
class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">
{{ issue.description|slice:":25" }}...
</th>
<td class="px-6 py-4">{{ issue.created|date:"F j, Y" }}</td>
<td class="px-6 py-4">{{ issue.get_label_display }}</td>
<td class="px-6 py-4">
{% if issue.status == 'open' %}
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">Open</span>
{% else %}
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-red-100 text-red-800">Closed</span>
{% endif %}
</td>
<td class="px-6 py-4 text-right">
<a href="{% url 'issue_view' issue.pk %}"
class="font-medium text-blue-600 hover:underline">View</a>
</td>
</tr>
{% endfor %}
{% else %}
<tr class="bg-white border-b">
<th scope="row"
class="px-6 py-4 font-medium text-red-500 whitespace-nowrap">No Issues Found</th>
<!-- Main Content -->
<div class="w-full mx-auto px-4 sm:px-6 lg:px-4 py-4">
<!-- Bugs List -->
{% if issues %}
<div class="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden">
<div class="px-6 py-4 border-b border-gray-200">
<h2 class="text-lg font-semibold text-gray-900">All Bugs</h2>
</div>
<table class="w-full">
<thead class="bg-gray-50 border-b border-gray-200">
<tr>
<th class="px-6 py-4 text-left text-sm font-semibold text-gray-900">Description</th>
<th class="px-6 py-4 text-left text-sm font-semibold text-gray-900">Created</th>
<th class="px-6 py-4 text-left text-sm font-semibold text-gray-900">Type</th>
<th class="px-6 py-4 text-left text-sm font-semibold text-gray-900">Status</th>
<th class="px-6 py-4 text-right text-sm font-semibold text-gray-900">Action</th>
</tr>
{% endif %}
</tbody>
</table>
</div>
</thead>
<tbody class="divide-y divide-gray-200">
{% if issues %}
{% for issue in issues %}
<tr class="hover:bg-gray-50 transition-colors duration-150">
<td class="px-6 py-4">
<div class="text-sm font-medium text-gray-900">
{{ issue.description|slice:":50" }}
{% if issue.description|length > 50 %}...{% endif %}
</div>
</td>
<td class="px-6 py-4">
<div class="text-sm text-gray-600">{{ issue.created|date:"M j, Y" }}</div>
</td>
<td class="px-6 py-4">
<div class="text-sm text-gray-600">{{ issue.get_label_display }}</div>
</td>
<td class="px-6 py-4">
{% if issue.status == 'open' %}
<span class="inline-flex px-3 py-1 text-xs font-medium bg-green-100 text-green-800 rounded-full">Open</span>
{% else %}
<span class="inline-flex px-3 py-1 text-xs font-medium bg-gray-100 text-gray-600 rounded-full">{{ issue.get_status_display }}</span>
{% endif %}
</td>
<td class="px-6 py-4 text-right">
<div class="flex items-center justify-end space-x-2">
<a href="{% url 'issue_view' issue.pk %}"
class="inline-flex items-center px-3 py-1.5 bg-gray-100 text-gray-700 rounded-lg hover:bg-gray-200 transition-all font-medium text-sm"
title="View Bug Details">
<svg class="w-4 h-4 mr-1.5"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"></path>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z">
</path>
</svg>
View
</a>
</div>
</td>
</tr>
{% endfor %}
{% endif %}
</tbody>
</table>
</div>
{% else %}
<!-- Empty State -->
<div class="bg-white rounded-lg border border-gray-200 p-8">
<div class="text-center">
<svg class="mx-auto h-16 w-16 text-gray-400"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v3m0 0v3m0-3h3m-3 0H9m12 0a9 9 0 11-18 0 9 9 0 0118 0z">
</path>
</svg>
<h3 class="mt-4 text-xl font-semibold text-gray-900">No bugs yet</h3>
<p class="mt-2 text-gray-500">Get started by reporting your first security issue.</p>
<div class="mt-6">
<a href="{% url 'report' %}"
class="inline-flex items-center px-4 py-2 bg-[#e74c3c] text-white rounded-lg hover:bg-red-600">
<svg class="w-5 h-5 mr-2"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"></path>
</svg>
Report Bug
</a>
</div>
</div>
</div>
{% endif %}
</div>
</div>
{% endblock body %}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h1 class="text-3xl font-bold text-gray-900">Manage Domains</h1>
<p class="mt-1 text-sm text-gray-500">Organize and control your domain portfolio</p>
</div>
<a href="{% url 'add_domain' organization %}"
class="inline-flex items-center px-4 py-3 bg-[#e74c3c] text-white rounded-xl font-medium hover:bg-red-700 transition-all duration-200 select-none">
class="inline-flex items-center px-4 py-2.5 bg-[#e74c3c] text-white rounded-xl font-medium hover:bg-red-700 transition-all duration-200 select-none">
<svg class="w-5 h-5 mr-2"
fill="none"
stroke="currentColor"
Expand Down Expand Up @@ -139,27 +139,27 @@ <h3 class="text-lg font-semibold text-gray-900">{{ domain.name|capfirst }}</h3>
</div>
{% else %}
<!-- Empty State -->
<div class="bg-white rounded-xl shadow-sm border border-gray-200 p-12">
<div class="bg-white rounded-lg border border-gray-200 p-8">
<div class="text-center">
<svg class="mx-auto h-12 w-12 text-gray-400"
<svg class="mx-auto h-16 w-16 text-gray-400"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9">
</path>
</svg>
<h3 class="mt-4 text-lg font-semibold text-gray-900">No domains yet</h3>
<p class="mt-2 text-sm text-gray-500">Get started by adding your first domain.</p>
<h3 class="mt-4 text-xl font-semibold text-gray-900">No domains yet</h3>
<p class="mt-2 text-gray-500">Get started by adding your first domain.</p>
<div class="mt-6">
<a href="{% url 'add_domain' organization %}"
class="inline-flex items-center px-4 py-2 bg-[#e74c3c] text-white rounded-lg hover:bg-red-700 transition-all duration-200">
class="inline-flex items-center px-4 py-2 bg-[#e74c3c] text-white rounded-lg hover:bg-red-600">
<svg class="w-5 h-5 mr-2"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"></path>
</svg>
Add Your First Domain
Add Domain
</a>
</div>
</div>
Expand Down Expand Up @@ -204,17 +204,6 @@ <h3 class="mt-4 text-lg font-semibold text-gray-900">No domains yet</h3>
});
});

// Add hover effects
const domainItems = document.querySelectorAll('.domain-item');
domainItems.forEach(item => {
item.addEventListener('mouseenter', function() {
this.style.transform = 'translateX(4px)';
});

item.addEventListener('mouseleave', function() {
this.style.transform = 'translateX(0)';
});
});
});
</script>
{% endblock body %}
47 changes: 30 additions & 17 deletions website/views/company.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,9 +751,14 @@ def post(self, request, id, *args, **kwargs):
messages.error(request, "Invalid domain url format")
return redirect("add_domain", id=id)

# Extract domain hostname and normalize to lowercase
domain = parsed_url.hostname.replace("www.", "").lower()
domain_data["name"] = domain_data["name"].lower()
# Extract domain hostname and normalize to lowercase for consistency
normalized_domain = parsed_url.hostname.replace("www.", "").lower()
# Ensure the domain name is consistent with the URL processing
# If user didn't provide a custom name, use the normalized domain
if domain_data["name"].lower().replace("www.", "") == normalized_domain:
domain_data["name"] = normalized_domain
else:
domain_data["name"] = domain_data["name"].strip()

managers_list = request.POST.getlist("user")
organization_obj = Organization.objects.get(id=id)
Expand Down Expand Up @@ -1580,14 +1585,16 @@ def post(self, request, id, *args, **kwargs):
messages.error(request, "Domain Does not exists")
return redirect("add_bughunt", id)

# Expect dates in MM/DD/YYYY format from the form
start_date = data.get("start_date", datetime.now().strftime("%m/%d/%Y"))
end_date = data.get("end_date", datetime.now().strftime("%m/%d/%Y"))

try:
# Parse MM/DD/YYYY format and convert to database format
start_date = datetime.strptime(start_date, "%m/%d/%Y").strftime("%Y-%m-%d %H:%M")
end_date = datetime.strptime(end_date, "%m/%d/%Y").strftime("%Y-%m-%d %H:%M")
except ValueError:
messages.error(request, "Invalid Date Format")
messages.error(request, "Please enter dates in MM/DD/YYYY format (e.g., 12/25/2024)")
return redirect("add_bughunt", id)

# apply validation for date not valid
Expand Down Expand Up @@ -1679,19 +1686,25 @@ def get(self, request, id, *args, **kwargs):
messages.error(request, "Organization does not exist")
return redirect("home")

query = Hunt.objects.values(
"id",
"name",
"prize",
"is_published",
"result_published",
"starts_on__day",
"starts_on__month",
"starts_on__year",
"end_on__day",
"end_on__month",
"end_on__year",
).filter(domain__organization__id=id)
query = (
Hunt.objects.values(
"id",
"name",
"prize",
"is_published",
"result_published",
"starts_on__day",
"starts_on__month",
"starts_on__year",
"end_on__day",
"end_on__month",
"end_on__year",
"url",
"logo",
)
.annotate(total_prize=Sum("huntprize__value"))
.filter(domain__organization__id=id)
)
filtered_bughunts = {
"all": query,
"ongoing": query.filter(result_published=False, is_published=True),
Expand Down
Loading