diff --git a/py_error_20190227040253.py b/py_error_20190227040253.py new file mode 100644 index 0000000..4639e73 --- /dev/null +++ b/py_error_20190227040253.py @@ -0,0 +1,46 @@ +#import lxml + +class C20190227040253(): + "This is an example class" + a = 10 + @classmethod + def funct(self): + print('Hello Example') + +# Output: 10 +print(C20190227040253.a) + +# Output: +print(C20190227040253.func) + +# Output: 'This is my second class' +print(C20190227040253.__doc__) + +# Code Injection +def GET(self): + get_input = web.input() + param1 = get_input['param1'] if 'param1' in get_input else None + if (param1): + x = ast.literal_eval(param1) + return "I'm not vulnerable"+x + +# CWE-759 +def storePassword(userName,Password): + hasher = hashlib.new('md5') + hasher.update(Password) + hashedPassword = hasher.digest() + + # UpdateUserLogin returns True on success, False otherwise + return updateUserLogin(userName,hashedPassword) + +def calc(number,times): + print("Sum =", a+b) + #no need for exec + for x in range(0, 3): + print("We're on time %d" % (x)) + y = 1 + while True: + if(y%2 ==0): + print("To infinity and beyond! We're getting close, on %d now!" % (y)) + y += 1 + return number*times \ No newline at end of file diff --git a/py_unittest_20190227040253.py b/py_unittest_20190227040253.py new file mode 100644 index 0000000..d0e55b2 --- /dev/null +++ b/py_unittest_20190227040253.py @@ -0,0 +1,15 @@ +from django.test import TestCase + + +from py_error_20190227040253 import C20190227040253 + +class TestModel01(TestCase): + + def test_01(self): + x = C20190227040253() + self.assertIs(x.a,10) + + + def test_02(self): + x = C20190227040253() + self.assertIs(x.calc(7,3),21) \ No newline at end of file diff --git a/py_xss_20190227040253.py b/py_xss_20190227040253.py new file mode 100644 index 0000000..83b98c4 --- /dev/null +++ b/py_xss_20190227040253.py @@ -0,0 +1,11 @@ +from flask import Flask, request, make_response, escape + +app = Flask(__name__) +@app.route('/unsafe') +def unsafe(): + first_name = request.args.get('name', '') + return make_response("Your name is " + first_name) +@app.route('/safe') +def safe(): + first_name = request.args.get('name', '') + return make_response("Your name is " + escape(first_name)) \ No newline at end of file diff --git a/static/js/js_error_20190227040253.js b/static/js/js_error_20190227040253.js new file mode 100644 index 0000000..ac1f616 --- /dev/null +++ b/static/js/js_error_20190227040253.js @@ -0,0 +1,10 @@ +function hello() { + let a = "dummy" + return "Hello"; +} + +function world() { + password a = "dummy" + let b = "line" + return "World"; +} \ No newline at end of file