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

modified: Dockerfile #6

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ COPY requirements.txt requirements.txt
RUN pip install --no-cache-dir -r requirements.txt


# copy project
COPY . /app/


# install pygoat
EXPOSE 8000
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# PyGoat
# PyGoat! :)
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-9-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->
Expand Down Expand Up @@ -126,3 +126,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
blabla bla bla bla
blaaaaaa
rrrrr
dddd
eeeee
JITTTT
30 changes: 27 additions & 3 deletions introduction/apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from introduction.playground.A9.main import Log
from introduction.playground.A6.utility import check_vuln
from django.contrib.auth import login,authenticate
from .utility import *
from django.views.decorators.csrf import csrf_exempt
import time
from .views import authentication_decorator
Expand All @@ -17,10 +18,33 @@
def ssrf_code_checker(request):
if request.user.is_authenticated:
if request.method == 'POST':
python_code = request.POST['python_code']
html_code = request.POST['html_code']
if not (ssrf_code_converter(python_code)):
return JsonResponse({"status": "error", "message": "Invalid code"})
test_bench1 = ssrf_html_input_extractor(html_code)

if (len(test_bench1) >4):
return JsonResponse({'message':'too many inputs in Html\n Try again'},status = 400)
test_bench2 = ['secret.txt']
correct_output1 = [{"blog": "blog1-passed"}, {"blog": "blog2-passed"}, {"blog": "blog3-passed"}, {"blog": "blog4-passed"}]
outputs = []
for inputs in test_bench1:
outputs.append(main.ssrf_lab(inputs))
if outputs == correct_output1:
outputs = []
else:
return JsonResponse({'message':'Testbench failed, Code is not working\n Try again'},status = 200)

correct_output2 = [{"blog": "No blog found"}]
for inputs in test_bench2:
outputs.append(main.ssrf_lab(inputs))
if outputs == correct_output2:
return JsonResponse({'message':'Congratulation, you have written a secure code.', 'passed':1}, status = 200)

return JsonResponse({'message':'Test bench passed but the code is not secure'}, status = 200,safe = False)
else:
return JsonResponse({'message':'1method not allowed'},status = 405)
return JsonResponse({'message':'method not allowed'},status = 405)
else:
return JsonResponse({'message':'UnAuthenticated User'},status = 401)

Expand Down Expand Up @@ -58,7 +82,7 @@ def log_function_checker(request):
f.close()
return JsonResponse({"message":"success", "logs": lines},status = 200)
else:
return JsonResponse({"message":"2method not allowed"},status = 405)
return JsonResponse({"message":"method not allowed"},status = 405)

#a7 codechecking api
@csrf_exempt
Expand Down Expand Up @@ -96,7 +120,7 @@ def A6_disscussion_api(request):
@csrf_exempt
def A6_disscussion_api_2(request):
if request.method != 'POST':
return JsonResponse({"message":"3method not allowed"},status = 405)
return JsonResponse({"message":"method not allowed"},status = 405)
try:
code = request.POST.get('code')
dirname = os.path.dirname(__file__)
Expand Down
5 changes: 5 additions & 0 deletions introduction/mitre.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ def csrf_transfer_monei_api(request,recipent,amount):
# @authentication_decorator
@csrf_exempt
def mitre_lab_25_api(request):
if request.method == "POST":
expression = request.POST.get('expression')
result = eval(expression)
Fixed Show fixed Hide fixed

Check failure

Code scanning / SonarCloud

Dynamic code execution should not be vulnerable to injection attacks High

Change this code to not dynamically execute code influenced by user-controlled data. See more on SonarCloud
return JsonResponse({'result': result})
else:
return redirect('/mitre/25/lab/')


Expand Down
6 changes: 6 additions & 0 deletions introduction/static/css/dark-theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ h2 {
padding: 17px;
border-radius: 10px;
text-align: center;
padding: 13% 0 0 0;
}
#owasp10_2017 {
width: 90%;
Expand All @@ -416,6 +417,7 @@ h2 {
padding: 17px;
border-radius: 10px;
text-align: center;
padding: 13% 0 0 0;
}

#sidebar li ul a #owasp10_2021 {
Expand All @@ -440,6 +442,7 @@ h2 {
padding: 17px;
border-radius: 10px;
text-align: center;
padding: 13% 0 0 0;
}

#homeSubmenu {
Expand All @@ -461,6 +464,7 @@ h2 {
padding: 17px;
border-radius: 10px;
text-align: center;
padding: 13% 0% 0% 0%;
}
#challengeSubmenu {
width: 95%;
Expand All @@ -484,6 +488,7 @@ h2 {
padding: 17px;
border-radius: 10px;
text-align: center;
padding: 13% 0% 0% 0%;
}
#mitre25 {
width: 90%;
Expand All @@ -494,6 +499,7 @@ h2 {
padding: 17px;
border-radius: 10px;
text-align: center;
padding: 13% 0% 0% 0%;
}

#stylesheet-toggle{
Expand Down
4 changes: 3 additions & 1 deletion introduction/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ def sql_lab(request):
print(sql_query)
try:
print("\nin try\n")
val=""
val=login.objects.raw(sql_query)
Fixed Show fixed Hide fixed
Copy link

Choose a reason for hiding this comment

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

Security control: Static Code Analysis Python Semgrep

Type: Gitlab.Bandit.B611

Description: You should be very careful whenever you write raw SQL. Consider using Django ORM before raw SQL. See https://docs.djangoproject.com/en/3.0/topics/db/sql/#passing-parameters-into-raw

Severity: HIGH

Learn more about this issue


Jit Bot commands and options (e.g., ignore issue)

You can trigger Jit actions by commenting on this PR review:

  • #jit_ignore_fp Ignore and mark this specific single instance of finding as “False Positive”
  • #jit_ignore_accept Ignore and mark this specific single instance of finding as “Accept Risk”
  • #jit_undo_ignore Undo ignore command

val=login.objects.raw(sql_query)
Fixed Show fixed Hide fixed
Copy link

Choose a reason for hiding this comment

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

Security control: Static Code Analysis Python Semgrep

Type: Gitlab.Bandit.B611

Description: You should be very careful whenever you write raw SQL. Consider using Django ORM before raw SQL. See https://docs.djangoproject.com/en/3.0/topics/db/sql/#passing-parameters-into-raw

Severity: HIGH

Learn more about this issue


Jit Bot commands and options (e.g., ignore issue)

You can trigger Jit actions by commenting on this PR review:

  • #jit_ignore_fp Ignore and mark this specific single instance of finding as “False Positive”
  • #jit_ignore_accept Ignore and mark this specific single instance of finding as “Accept Risk”
  • #jit_undo_ignore Undo ignore command

Choose a reason for hiding this comment

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

#jit_ignore_fp

val=login.objects.raw(sql_query)
Fixed Show fixed Hide fixed
Copy link

Choose a reason for hiding this comment

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

Security control: Static Code Analysis Python Semgrep

Type: Gitlab.Bandit.B611

Description: You should be very careful whenever you write raw SQL. Consider using Django ORM before raw SQL. See https://docs.djangoproject.com/en/3.0/topics/db/sql/#passing-parameters-into-raw

Severity: HIGH

Learn more about this issue


Jit Bot commands and options (e.g., ignore issue)

You can trigger Jit actions by commenting on this PR review:

  • #jit_ignore_fp Ignore and mark this specific single instance of finding as “False Positive”
  • #jit_ignore_accept Ignore and mark this specific single instance of finding as “Accept Risk”
  • #jit_undo_ignore Undo ignore command

except:
print("\nin except\n")
return render(
Expand Down