Skip to content

Commit 1b43a50

Browse files
authored
Merge pull request #16 from prompt-security/make_debug_level_configurable_only_on_commandline
Make debug level configurable only on command line
2 parents b148e35 + ae71d66 commit 1b43a50

File tree

3 files changed

+5
-31
lines changed

3 files changed

+5
-31
lines changed

ps_fuzz/app_config.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import colorama
55
from .util import wrap_text
66
from .results_table import print_table
7-
from .ps_logging import setup_logging
87
import logging
98
logger = logging.getLogger(__name__)
109

@@ -17,8 +16,7 @@ class AppConfig:
1716
'num_attempts': 3,
1817
'num_threads': 4,
1918
'attack_temperature': 0.6,
20-
'debug_level': 1,
21-
'system_prompt': ''
19+
'system_prompt': '',
2220
}
2321

2422
def __init__(self, config_state_file: str):
@@ -131,17 +129,6 @@ def num_threads(self, value: int):
131129
self.config_state['num_threads'] = value
132130
self.save()
133131

134-
@property
135-
def debug_level(self) -> int:
136-
return self.config_state['debug_level']
137-
138-
@debug_level.setter
139-
def debug_level(self, value: int):
140-
if not (0 <= value <= 2): raise ValueError("Debug level must be between 0 and 2")
141-
self.config_state['debug_level'] = value
142-
setup_logging(value) # Update logging level based on configured debug level
143-
self.save()
144-
145132
@property
146133
def system_prompt(self) -> str:
147134
return self.config_state['system_prompt']

ps_fuzz/cli.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from dotenv import load_dotenv
66
dotenv_path = os.path.join(os.getcwd(), '.env')
77
load_dotenv(dotenv_path)
8+
from .ps_logging import setup_logging
89
from .chat_clients import *
910
from .client_config import ClientConfig
1011
from .attack_config import AttackConfig
@@ -46,6 +47,9 @@ def main():
4647
print(f" {BRIGHT}{test_name}{RESET}: {test_description}")
4748
sys.exit(0)
4849

50+
# Setup debug level (default 1)
51+
setup_logging(args.debug_level if args.debug_level is not None else 1)
52+
4953
# Load application config from file (if exists)
5054
app_config = AppConfig(APP_CONFIG_FILE)
5155

ps_fuzz/interactive_mode.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ def show(cls, state: AppConfig):
5353
['Fuzzer Configuration', None, FuzzerOptions],
5454
['Target LLM Configuration', None, TargetLLMOptions],
5555
['Attack LLM Configuration', None, AttackLLMOptions],
56-
['Debug Level', None, DebugOptions],
5756
['Show all configuration', show_all_config, MainMenu],
5857
['Exit', None, None],
5958
]
@@ -99,22 +98,6 @@ def show(cls, state: AppConfig):
9998
state.num_attempts = int(result['num_attempts'])
10099
return MainMenu
101100

102-
class DebugOptions:
103-
@classmethod
104-
def show(cls, state: AppConfig):
105-
print("Debug Options: Review and modify the debug log level")
106-
print("----------------------------------------------------")
107-
result = inquirer.prompt([
108-
inquirer.Text('debug_level',
109-
message="Debug Level (0-2) (0=warnings and errors; 1 = normal; 2 = verbose)",
110-
default=str(state.debug_level),
111-
validate=lambda _, x: x.isdigit() and int(x) > 0
112-
),
113-
])
114-
if result is None: return # Handle prompt cancellation concisely
115-
state.debug_level = int(result['debug_level'])
116-
return MainMenu
117-
118101
class TargetLLMOptions:
119102
@classmethod
120103
def show(cls, state: AppConfig):

0 commit comments

Comments
 (0)