Skip to content

Commit 23a5e54

Browse files
committed
Remove all password recommendations.
Add a function to retrieve the vulnerabilities file path using vulnerability ID. Signed-off-by: ziad hany <ziadhany2016@gmail.com>
1 parent d8ef695 commit 23a5e54

3 files changed

Lines changed: 39 additions & 23 deletions

File tree

fedcode/pipes/utils.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#
99

1010
import json
11+
import os
1112

1213
import saneyaml
1314
from packageurl import PackageURL
@@ -95,3 +96,22 @@ def get_scan_note(path):
9596
},
9697
],
9798
}
99+
100+
101+
def get_vulnerability_path(repo_path: str, vulnerability_id: str) -> str:
102+
"""
103+
Get the vulnerability file path using repo_path and vulnerability_id.
104+
Raise FileNotFoundError if the file does not exist.
105+
"""
106+
vul_filepath = os.path.join(
107+
repo_path,
108+
f"aboutcode-vulnerabilities-{vulnerability_id[5:7]}",
109+
vulnerability_id[10:12],
110+
vulnerability_id,
111+
f"{vulnerability_id}.yml",
112+
)
113+
114+
if not os.path.exists(vul_filepath):
115+
raise FileNotFoundError(f"Vulnerability file not found: {vul_filepath}")
116+
117+
return vul_filepath

fedcode/templates/user_sign_up.html

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,45 +29,39 @@
2929
</div>
3030
{% endif %}
3131

32-
<h2 class="title">User Signup</h2>
32+
<h2 class="title">Create your FederatedCode Account</h2>
3333
<form method="post">
3434
{% csrf_token %}
3535
<div class="field">
3636
<div class="control">
37-
<input class="input" placeholder="Username" type="text" name="username" maxlength="150" autofocus required
37+
<label class="label" for="id_username">Username</label>
38+
<input class="input" placeholder="Username" type="text" name="username" maxlength="150" autofocus required
3839
id="id_username">
39-
<span class="help">
40-
Only letters, numbers, and <strong>@ . + - _</strong> allowed.
41-
</span>
4240
</div>
4341
</div>
4442
<div class="field">
4543
<div class="control">
44+
<label class="label" for="id_email">Email</label>
4645
<input class="input" type="email" placeholder="Email" name="email" maxlength="254" required id="id_email">
4746
</div>
4847
</div>
4948
<div class="field">
5049
<div class="control">
51-
<input class="input" type="password" placeholder="Password" name="password1" autocomplete="new-password"
50+
<label class="label" for="id_password1">Password</label>
51+
<input class="input" type="password" placeholder="Create a password" name="password1" autocomplete="new-password"
5252
required id="id_password1">
53-
<span class="help">
54-
<ul>
55-
<li>Password can't be too similar to your other personal information.</li>
56-
<li>Password must contain at least 8 characters.</li>
57-
<li>Password can't be a commonly used password.</li>
58-
<li>Password can't be entirely numeric.</li>
59-
</ul>
60-
</span>
6153

6254
</div>
6355
</div>
6456
<div class="field">
6557
<div class="control">
66-
<input class="input" type="password" placeholder="Confirm password" name="password2"
58+
<label class="label" for="id_password2">Confirm Password</label>
59+
<input class="input" type="password" placeholder="Confirm your password" name="password2"
6760
autocomplete="new-password" required id="id_password2">
6861
</div>
6962
</div>
7063
<div class="field">
64+
<label class="label">Verification</label>
7165
<div class="control">
7266
{{ form.captcha }}
7367
</div>

fedcode/views.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
from fedcode.models import Review
6969
from fedcode.models import SyncRequest
7070
from fedcode.models import Vulnerability
71+
from fedcode.pipes.utils import get_vulnerability_path
7172
from fedcode.signatures import FEDERATEDCODE_PUBLIC_KEY
7273
from fedcode.signatures import HttpSignature
7374
from fedcode.utils import ap_collection
@@ -810,16 +811,17 @@ def redirect_repository(request, repository_id):
810811
def redirect_vulnerability(request, vulnerability_id):
811812
try:
812813
vul = Vulnerability.objects.get(id=vulnerability_id)
813-
vul_filepath = os.path.join(
814-
vul.repo.path,
815-
f"./aboutcode-vulnerabilities-{vulnerability_id[5:7]}/{vulnerability_id[10:12]}"
816-
f"/{vulnerability_id}/{vulnerability_id}.yml",
817-
)
818-
with open(vul_filepath) as f:
819-
return HttpResponse(json.dumps(f.read()))
814+
815+
repo_path = vul.repo.path
816+
vul_filepath = get_vulnerability_path(repo_path, vulnerability_id)
817+
818+
with open(vul_filepath, encoding="utf-8") as f:
819+
return HttpResponse(json.dumps(f.read()), content_type="application/json")
820820

821821
except Vulnerability.DoesNotExist:
822-
return Http404("Vulnerability does not exist")
822+
raise Http404("Vulnerability does not exist")
823+
except FileNotFoundError:
824+
raise Http404("Vulnerability file not found")
823825

824826

825827
class UserFollowing(View):

0 commit comments

Comments
 (0)