From 093414ff57148035a033bb955cba9dff5e6fc0fb Mon Sep 17 00:00:00 2001 From: Fawwaz Anugrah Wiradhika Dharmasatya <anugrahdwfawwaz@gmail.com> Date: Wed, 5 Jun 2024 13:49:05 +0700 Subject: [PATCH] feat: handle class in module riute tag --- src/lib/ACLAnalyzer.py | 3 ++- tests/tc1/class_views.py | 5 +---- tests/tc1/lib/RoleCheck.py | 2 +- todo.txt | 5 ++--- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/lib/ACLAnalyzer.py b/src/lib/ACLAnalyzer.py index 2bdba8d..3c038b6 100644 --- a/src/lib/ACLAnalyzer.py +++ b/src/lib/ACLAnalyzer.py @@ -422,8 +422,9 @@ class ACLAnalyzer(): if f['type']=='class_method': #TODO class method ctx = ElementContext(f"{f['parent']}.{f['name']}",'function',route.location,[]) + ctx.set_cfg(CFG(f['ast'],f['ctx'],f['cursor'],route.cfg.source_code_method_list,route.cfg.source_code)) result = self.analyze_function(ctx) - route_acls.append([f"{f['parent']}.{ctx.get_base_element_name()}",result]) + route_acls.append([ctx.get_base_element_name(),result]) else: ctx = ElementContext(f['name'],'function',route.location,[]) ctx.set_cfg(CFG(f['ast'],f['ctx'],f['cursor'],route.cfg.source_code_method_list,route.cfg.source_code)) diff --git a/tests/tc1/class_views.py b/tests/tc1/class_views.py index d987f4f..8cf5b48 100644 --- a/tests/tc1/class_views.py +++ b/tests/tc1/class_views.py @@ -1,3 +1,4 @@ +# @Routes from flask import Blueprint, render_template, request, flash, jsonify,abort # @ACL(login_required) from flask_login import login_required, current_user @@ -5,13 +6,10 @@ from .models import Note,Log from .db import db import json from lib.RoleCheck import RoleCheck - views = Blueprint('views', __name__) class Views(): - # @NoCheck def __init__(self) -> None: pass -# @Routes @views.route('/add', methods=['POST']) @login_required def class_add_note(self): @@ -63,7 +61,6 @@ class Views(): def class_get_note(self): notes = Note.query.filter(Note.user_id==current_user.id) return jsonify(notes) -# @Routes @views.route('/logs', methods=['GET']) @login_required def class_get_logs(self): diff --git a/tests/tc1/lib/RoleCheck.py b/tests/tc1/lib/RoleCheck.py index c7932b6..fabcba9 100644 --- a/tests/tc1/lib/RoleCheck.py +++ b/tests/tc1/lib/RoleCheck.py @@ -1,5 +1,5 @@ -class RoleCheck(): # @ACL +class RoleCheck(): def is_admin(self,user)->bool: return user.role == 'admin' def is_authenticated(self, user)->bool: diff --git a/todo.txt b/todo.txt index 997be45..88dae6f 100644 --- a/todo.txt +++ b/todo.txt @@ -1,4 +1,3 @@ - exempt function in module -- tes buat function in class -- acl function in class called from function in class -- formatting name for class method in module type \ No newline at end of file +- cek kasus buat class in module +- Per NoCheck an belum dites \ No newline at end of file -- GitLab