diff --git a/src/lib/FileReader.py b/src/lib/FileReader.py index 1db79a08ee36d1a6c9be14d41670c0e441b9c1fc..ac81b2f46dc58db9c96f75fdf1c4c70a6bd1486d 100644 --- a/src/lib/FileReader.py +++ b/src/lib/FileReader.py @@ -25,6 +25,7 @@ class FileReader: lines = source_code.readlines() i = 0 while i < len(lines): + is_skipped = False annotation_list = self.have_annotation(lines[i]) annotation = None if len(annotation_list)==0 else annotation_list[0] if(annotation): @@ -33,8 +34,19 @@ class FileReader: # skip fungsi ini # Cari tahu jenis yang di-excempt i+=1 - while re.search("\S*@.+",lines[i]): + while not is_skipped and re.search("\S*@.+",lines[i]): + next_annotations = self.have_annotation(lines[i]) + # print(next_annotations) + for annon in next_annotations: + if "@Routes" in annon: + # Skip fungsi ini + is_skipped = True + break + #TODO handle sisanya i+=1 + if is_skipped: + # print("skip") + continue # Kalau next line nya class, ya class, kalau def yg fungsi, selain itu type nya module curr_node = None if re.search("\S*class +",lines[i]): @@ -69,6 +81,7 @@ class FileReader: # Cari tahu jenis acl nya i+=1 while re.search("\S*@.+",lines[i]): + #TODO handle kalau ketemu yang lain i+=1 if re.search("\S*class +",lines[i]): # ACL nya kelas @@ -100,8 +113,17 @@ class FileReader: additional_context = re.sub(r"[\(\) ]","",match.group(0)).split(",") # Cari tahu jenis rute nya i+=1 - while re.search("\S*@.+",lines[i]): + while not is_skipped and re.search("\S*@.+",lines[i]): + next_annotations = self.have_annotation(lines[i]) + for annon in next_annotations: + if "@NoCheck" in annon: + # Skip fungsi ini + is_skipped = True + break + #TODO handle sisanya i+=1 + if is_skipped: + continue # Kalau next line nya class, ya class, kalau def yg fungsi, selain itu type nya module if re.search("\S*class +",lines[i]): project_info.route_class.append(ElementContext(lines[i].strip().split(" ")[1],'class',file,additional_context)) diff --git a/tests/tc1/acl.txt b/tests/tc1/acl.txt index 13f3317a55dba6df3437654eba6721f3069574ee..93943d20867ec03aa4f221fe4c320d940a444650 100644 --- a/tests/tc1/acl.txt +++ b/tests/tc1/acl.txt @@ -11,6 +11,7 @@ Views.class_update_note:admin,user Views.class_delete_note:admin,user Views.class_get_note:admin,user Views.class_get_logs: admin +logout: admin,user =====DETAIL===== var:user::var:role; [admin:admin,user:user,none:guest] lib:flask_login::login_required; admin,user \ No newline at end of file diff --git a/tests/tc1/auth.py b/tests/tc1/auth.py index cf676572ba855d7ad959ba4d774baa7e4cafabf0..2f81ba692ee86a341a5db6a273c77e2699f58e60 100644 --- a/tests/tc1/auth.py +++ b/tests/tc1/auth.py @@ -2,6 +2,7 @@ from flask import Blueprint, render_template, request, flash, redirect, url_for from .models import User from werkzeug.security import generate_password_hash, check_password_hash from . import db +#@ACL(login_required) from flask_login import login_user, login_required, logout_user, current_user @@ -26,7 +27,7 @@ def login(): return render_template("login.html") - +#@Routes @auth.route('/logout') @login_required def logout(): diff --git a/tests/tc1/class_views.py b/tests/tc1/class_views.py index 8db2977480e6ce5f7fada6d0142bff5f5c541309..5af9e22e7784200de747fc894fad9b0907cbb1ca 100644 --- a/tests/tc1/class_views.py +++ b/tests/tc1/class_views.py @@ -5,9 +5,8 @@ from .models import Note,Log from .db import db import json from lib.RoleCheck import RoleCheck -# @Routes -views = Blueprint('views', __name__) +views = Blueprint('views', __name__) class Views(): def __init__(self,a) -> None: self.a = a @@ -26,7 +25,8 @@ class Views(): flash('Note added!', category='success') return render_template("home.html") - +# @NoCheck +# @Routes @views.route('/update', methods=['POST']) @login_required def class_update_note(self): diff --git a/tests/tc1/views.py b/tests/tc1/views.py index ac11e48289fe84af81f90125cc4cf09c4d320a3b..fbb3a7dc2bdba188ffa00f5403d77996a8ab6548 100644 --- a/tests/tc1/views.py +++ b/tests/tc1/views.py @@ -1,3 +1,4 @@ +# @NoCheck # @Routes from flask import Blueprint, render_template, request, flash, jsonify,abort # @ACL(login_required) diff --git a/todo.txt b/todo.txt index 23c8984ab7132e255dc559490373a3455e73d6fe..c443f20a04f307866c99eab89ce734b97c463522 100644 --- a/todo.txt +++ b/todo.txt @@ -8,6 +8,31 @@ module: - class > function (V) TODO -- check kalau kelasnya disimpan di variabel (V) -> cuma kalau langsung manggil kelas +- check kalau kelasnya disimpan di variabel (V) -> cuma kalau langsung manggil kelas ( 1 kali assignment, belum transitif) - routes kena nocheck? -- default gak cek __init__ (V) \ No newline at end of file +routes -> nocheck +function (V) +class: (V) + - function (V) +module: (V) + - function (V) + - class (V) + - class > function (V) +nocheck -> routes +function (V) +class:(V) + - function (V) +module: (V) + - function (V) + - class (V) + - class > function (V) +- acl sekaligus routes? +routes -> acl +acl -> routes +nocheck -> acl +acl -> nocheck +routes -> routes +nocheck -> nocheck +acl -> acl +- default gak cek __init__ (V) +- routes dalam routes (module -> function) \ No newline at end of file