Skip to content

Commit 26ef4fe

Browse files
Merge branch 'main' into ai-project-enhancement
2 parents 7ea34a5 + 6cadf5b commit 26ef4fe

24 files changed

+1257
-184
lines changed

.github/workflows/enforce-issue-number-in-description.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ permissions:
1616
jobs:
1717
validate_pr_closing_issues:
1818
runs-on: ubuntu-latest
19+
if: github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]' && github.actor != 'dependabot'
1920
steps:
2021
- name: Validate PR closing issues with GraphQL
2122
env:

Dockerfile

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,47 @@
1-
FROM python:3.11.2
1+
# Stage 1: Build stage
2+
FROM python:3.11.2 AS builder
23

34
ENV PYTHONUNBUFFERED 1
4-
RUN mkdir /blt
55
WORKDIR /blt
6-
COPY . /blt
7-
86

9-
# Install PostgreSQL dependencies
7+
# Install system dependencies
108
RUN apt-get update && \
11-
apt-get install -y postgresql-client libpq-dev && \
9+
apt-get install -y postgresql-client libpq-dev \
10+
libmemcached11 libmemcachedutil2 libmemcached-dev libz-dev \
11+
dos2unix && \
1212
rm -rf /var/lib/apt/lists/*
1313

14-
# Install pylibmc dependencies
15-
RUN apt-get update && apt-get install -y \
16-
libmemcached11 \
17-
libmemcachedutil2 \
18-
libmemcached-dev \
19-
libz-dev
20-
21-
22-
RUN pip install poetry
14+
# Install Poetry and dependencies
15+
RUN pip install poetry
2316
RUN poetry config virtualenvs.create false
17+
COPY pyproject.toml poetry.lock* ./
2418
RUN poetry install
19+
20+
# Install additional Python packages
2521
RUN pip install opentelemetry-api opentelemetry-instrumentation
2622

27-
# Install dos2unix
28-
RUN apt-get update && apt-get install -y dos2unix
23+
# Stage 2: Runtime stage
24+
FROM python:3.11.2-slim
25+
26+
ENV PYTHONUNBUFFERED 1
27+
WORKDIR /blt
28+
29+
# Copy only necessary files from builder stage
30+
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
31+
COPY --from=builder /usr/local/bin /usr/local/bin
2932

30-
# Add entrypoint
33+
# Install runtime system dependencies
34+
RUN apt-get update && \
35+
apt-get install -y postgresql-client libpq-dev \
36+
libmemcached11 libmemcachedutil2 dos2unix && \
37+
rm -rf /var/lib/apt/lists/*
3138

32-
COPY entrypoint.sh /entrypoint.sh
33-
RUN dos2unix .env Dockerfile docker-compose.yml entrypoint.sh ./blt/settings.py
34-
RUN chmod +x /entrypoint.sh
39+
# Copy application code
40+
COPY . /blt
3541

42+
# Convert line endings and set permissions
43+
RUN dos2unix .env Dockerfile docker-compose.yml entrypoint.sh ./blt/settings.py
44+
RUN chmod +x /blt/entrypoint.sh
3645

37-
ENTRYPOINT [ "./entrypoint.sh" ]
38-
CMD [ "poetry", "run", "python", "manage.py", "runserver", "0.0.0.0:8000" ]
46+
ENTRYPOINT ["/blt/entrypoint.sh"]
47+
CMD ["poetry", "run", "python", "manage.py", "runserver", "0.0.0.0:8000"]

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,14 @@
77
<img alt="Views" src="https://blt.owasp.org/projects/blt/badge"></a>
88

99
Everything is on our <a href="https://blt.owasp.org">homepage</a>
10+
11+
## Star History
12+
13+
<a href="https://star-history.com/#OWASP-BLT/BLT&Date">
14+
<picture>
15+
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=OWASP-BLT/BLT&type=Date&theme=dark" />
16+
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=OWASP-BLT/BLT&type=Date" />
17+
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=OWASP-BLT/BLT&type=Date" />
18+
</picture>
19+
</a>
20+

Setup.md

Lines changed: 79 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,37 +17,84 @@ cp .env.example .env
1717
- Modify the .env file as per your local setup.
1818

1919
## Step 2: Choose your setup method (Docker recommended)
20-
### 1.Recommended method: Setting up development server using docker-compose
21-
22-
- Install docker
23-
24-
25-
```sh
26-
# --- build the docker container ---
27-
docker-compose build
28-
29-
# --- Run the docker container ---
30-
docker-compose up
31-
32-
# --- Collect static files ---
33-
34-
### open container bash terminal
35-
# `app` is the service name in docker-compose.yml
36-
docker exec -it app /bin/bash
37-
38-
# Below commands are for container shell
39-
### migrate SQL commands in the database file
40-
python manage.py migrate
41-
42-
### collect staticfiles
43-
python manage.py collectstatic
44-
45-
# --- exit out of container shell ---
46-
exit
47-
48-
```
49-
50-
### 2.Setting up development server using vagrant
20+
#### Prerequisites for Docker method
21+
Ensure the following are installed on your system before proceeding:
22+
23+
- Docker
24+
- Docker Compose
25+
- PostgreSQL client (optional, for manual database interaction)
26+
27+
---
28+
29+
### 1. Ensure LF Line Endings
30+
Before building the Docker images, ensure all files, especially scripts like `entrypoint.sh`, `.env`, `docker-compose.yml`, `Dockerfile`, `settings.py` use LF line endings. Using CRLF can cause build failures. To verify and correct line endings:
31+
32+
1. If you're working on a Windows machine or collaborating across different operating systems, ensure consistent line endings:
33+
- Set `core.autocrlf=input` in Git configurations to enforce LF-style line endings in the repository while preserving your local OS line endings.
34+
```bash
35+
git config --global core.autocrlf input
36+
```
37+
- Alternatively, in VS Code, you can manually change the line endings:
38+
- Open the file in the editor.
39+
- Look for the line ending type displayed in the bottom-right corner of the VS Code window (e.g., CRLF or LF).
40+
- Click it and select "LF: Unix" from the dropdown to switch the line endings to LF.
41+
42+
2. If the browser **automatically redirects to HTTPS** even in incognito mode, you can try the following:
43+
For **local development**, make these adjustments in `/blt/settings.py` to enable access over **HTTP**:
44+
- Set:
45+
```python
46+
SECURE_SSL_REDIRECT = False
47+
SECURE_PROXY_SSL_HEADER = None
48+
```
49+
50+
3. To convert to LF (if needed):
51+
- Using `dos2unix`:
52+
```bash
53+
dos2unix entrypoint.sh
54+
```
55+
56+
⚠️ **Important:**
57+
- If line endings are not set to LF, running `docker-compose build` may fail.
58+
- Avoid creating a PR to commit these local changes back to the repository.
59+
60+
### 2. PostgreSQL Setup
61+
The PostgreSQL database listens on a port specified in the .env file.
62+
Default is 5432 and
63+
If you encounter conflicts, it might be set to another port (e.g., 5433 in some cases). Adjust the .env file accordingly.
64+
65+
---
66+
67+
## Commands to Set Up the Project
68+
69+
- **Copy and configure the `.env` file:**
70+
```bash
71+
cp .env.example .env
72+
Update credentials and settings as needed.
73+
74+
- #### Build the Docker images:
75+
```bash
76+
docker-compose build
77+
- #### Start the containers:
78+
```bash
79+
docker-compose up
80+
- #### Access the application:
81+
82+
- Open your browser and navigate to:
83+
http://localhost:8000/
84+
- #### Prevent Automatic Redirects to HTTPS:
85+
- Use Incognito Mode (Private Browsing): Open the browser in incognito mode and access the application using http://localhost:8000.
86+
- Ensure you're explicitly using http:// instead of https:// in the URL.
87+
### Notes
88+
- The project listens on port 8000 over the HTTP protocol.
89+
- Ensure all required configurations in .env are correct for seamless setup.
90+
91+
### Error Edge Cases
92+
- If container fails execute ./entrypoint.sh due to permission error, use `chmod +x ./entrypoint.sh`
93+
- If you encounter ./entrypoint.sh was not found, then make sure you are using `LF` line ending in place of `CRLF`
94+
- If you encounter ERR_SSL_PROTOCOL_ERROR when you try to access the server on http://localhost:8000, make sure the Browser doesn't automatically redirect to https://localhost:8000. If it keeps doing this behaviour, then you can set `SECURE_SSL_REDIRECT` to `False` locally only(search for it /blt/settings.py), stop the container and start it again.
95+
- If you encounter the same error indicating SSL_REDIRECT in the logs while building the container, set `SECURE_SSL_REDIRECT` to `False`
96+
97+
### Option 2.Setting up development server using vagrant
5198
5299
-Install [vagrant](https://www.vagrantup.com/)
53100
@@ -89,7 +136,7 @@ Add a Domain `http://127.0.0.1:8000/admin/website/domain/` with the name 'owasp.
89136
**Note:** In case you encounter an error with vagrant's vbguest module, run `vagrant plugin install vagrant-vbguest`
90137
from the host machine.
91138
92-
### 3.Setting up development server using python virtual environment
139+
### Option 3.Setting up development server using python virtual environment
93140
94141
#### Setup correct python version
95142

blt/urls.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@
121121
admin_company_dashboard,
122122
admin_company_dashboard_detail,
123123
approve_activity,
124+
checkIN,
125+
checkIN_detail,
124126
company_dashboard,
125127
company_dashboard_domain_detail,
126128
company_dashboard_hunt_detail,
@@ -162,6 +164,7 @@
162164
UserProfileDetailView,
163165
addbalance,
164166
assign_badge,
167+
badge_user_list,
165168
contributors,
166169
contributors_view,
167170
create_wallet,
@@ -473,6 +476,11 @@
473476
badge_list,
474477
name="badges",
475478
),
479+
re_path(
480+
r"^badges/(?P<badge_id>\d+)/users/$",
481+
badge_user_list,
482+
name="badge_user_list",
483+
),
476484
re_path(r"^start/$", TemplateView.as_view(template_name="hunt.html"), name="start_hunt"),
477485
re_path(r"^hunt/$", login_required(HuntCreate.as_view()), name="hunt"),
478486
re_path(r"^hunts/$", ListHunts.as_view(), name="hunts"),
@@ -639,6 +647,8 @@
639647
path("auth/delete", AuthApiViewset.as_view({"delete": "delete"}), name="auth-delete-api"),
640648
path("api/v1/tags", TagApiViewset.as_view({"get": "list", "post": "create"}), name="tags-api"),
641649
path("sizzle/", sizzle, name="sizzle"),
650+
path("check-in/", checkIN, name="checkIN"),
651+
path("check-in/<int:report_id>/", checkIN_detail, name="checkIN_detail"),
642652
path("sizzle-docs/", sizzle_docs, name="sizzle-docs"),
643653
path("api/timelogsreport/", TimeLogListAPIView, name="timelogsreport"),
644654
path("time-logs/", TimeLogListView, name="time_logs"),

company/views.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,18 @@ def post(self, request, *args, **kwargs):
142142

143143
user_domain = get_email_domain(user.email)
144144
company_name = data.get("company_name", "")
145+
company_url = data.get("company_url", "")
145146

146147
if user_domain in restricted_domain:
147148
messages.error(request, "Login with company email in order to create the company.")
148149
return redirect("/")
149150

150-
if Company.objects.filter(name=company_name).exists():
151-
messages.error(request, "Company already exists.")
151+
if company_name == "" or Company.objects.filter(name=company_name).exists():
152+
messages.error(request, "Company name is invalid or already exists.")
153+
return redirect("register_company")
154+
155+
if company_url == "" or Company.objects.filter(url=company_url).exists():
156+
messages.error(request, "Company URL is invalid or already exists.")
152157
return redirect("register_company")
153158

154159
company_logo = request.FILES.get("logo")

0 commit comments

Comments
 (0)