<commit_before># Copyright (C) 2001-2003 Tresys Technology, LLC
# see file 'COPYING' for use and warranty information 

# TCL/TK GUI for SE Linux policy analysis
# Requires tcl and tk 8.3+, with BWidgets 

##############################################################
# ::ApolTop
#  
# The top level GUI
##############################################################
namespace eval ApolTop {
	# All capital letters is the convention for variables defined via the Makefile.
	variable bwidget_version	""
	variable status 		""
	variable polversion 		""
	variable policy_type		""
	variable binary_policy_type	"binary"
	variable source_policy_type	"source"
	variable filename 		""
	# The following is used with opening a policy for loading all or pieces of a policy. 
	# The option defaults to 0 (or all portions of the policy).
	variable policy_open_option	0
	variable policyConf_lineno	""
	variable polstats 		""
	# The version number is defined as a magical string here. This is later configured in the make environment.
	variable gui_ver 		APOL_GUI_VERSION 
	variable copyright_date		"2001-2004"
	# install_dir is a magical string to be defined via the makefile!
	variable apol_install_dir	APOL_INSTALL_DIR
	variable recent_files
	variable num_recent_files 	0
	variable most_recent_file 	-1
	# The max # can be changed by the .apol file
	variable max_recent_files 	5
	# env array element HOME is an environment variable
	variable dot_apol_file 		"[file join "$::env(HOME)" ".apol"]"
	variable goto_line_num
	# Default GUI settings
	variable prevCursor		arrow
	variable default_bg_color
	variable text_font		""
	variable title_font		""
	variable dialog_font		""
	variable general_font		""
	variable temp_recent_files	""
	variable query_file_ext 	".qf"
	# Main window dimension defaults
        variable top_width             1000
        variable top_height            700
	
	# Top-level dialog widgets
	variable helpDlg
	set helpDlg .apol_helpDlg
	variable searchDlg
	set searchDlg .searchDlg
	variable goto_Dialog
	set goto_Dialog .goto_Dialog
	variable options_Dialog
	set options_Dialog .options_Dialog
	
	######################
	# Other global widgets
	variable mainframe
	variable textbox_policyConf
	variable searchDlg_entryBox
	variable gotoDlg_entryBox
	# Main top-level notebook widget
	variable notebook
	# Subordinate notebook widgets
	variable components_nb
	variable rules_nb
	
	# Search-related variables
	variable searchString		""
	variable case_Insensitive	0
	variable regExpr 		0
	variable srch_Direction		"down"
	variable policy_is_open		0
	
	# Notebook tab IDENTIFIERS; NOTE: We name all tabs after their related namespace qualified names.
	# We use the prefix 'Apol_' for all notebook tabnames. Note that the prefix must end with an 
	# underscore and that that tabnames may NOT have a colon.
	variable tabName_prefix		"Apol_"
	variable components_tab 	"Apol_Components"
    	variable rules_tab 		"Apol_Rules"
	variable types_tab		"Apol_Types"
	variable terules_tab		"Apol_TE"
	variable roles_tab		"Apol_Roles"
	variable rbac_tab		"Apol_RBAC"
	variable class_perms_tab	"Apol_Class_Perms"
	variable users_tab		"Apol_Users"
	variable initial_sids_tab	"Apol_Initial_SIDS"
	variable cond_bools_tab		"Apol_Cond_Bools"
	variable cond_rules_tab		"Apol_Cond_Rules"
	variable policy_conf_tab	"Apol_PolicyConf"
	variable analysis_tab		"Apol_Analysis"
	 
	variable tk_msgBox_Wait

# "contents" indicates which aspects of the policy are included in the current opened policy file
# indicies into this array are:
# 	classes
#	perms			(inlcudes common perms)
#	types			(include attribs)
#	te_rules		(all type enforcement rules)
#	roles			
#	rbac			(all role rules)
#	users
        variable contents

# initialize the recent files list
	for {set i 0} {$i<$max_recent_files } {incr i} {
		set recent_files($i) ""
	}

# NOTE: We no longer need to include these tab files at run-time; instead
#	we create a single.tcl file at compile time.
# below allows separate files for each "tab" on the app
#    set pwd [pwd]
#    cd [file dirname [info script]]
#    variable MYDIR [pwd]
#    foreach script {
#	types_tab.tcl terules_tab.tcl \
#	roles_tab.tcl rbac_tab.tcl \
#	classes_perms_tab.tcl users_tab.tcl policyconf.tcl
#   } {
#	namespace inscope :: source $script
#    }
#    cd $pwd    

	# store the default background color for use when diabling widgets
	set default_bg_color [. cget -background] 

}

proc ApolTop::is_policy_open {} {
	return $ApolTop::policy_is_open
}

proc ApolTop::get_install_dir {} {
	return $ApolTop::apol_install_dir
}

########################################################################
# ::load_perm_map_fileDlg -- 
#	- Called from Advanced menu
proc ApolTop::load_perm_map_fileDlg {} {
	variable mainframe
	set rt [Apol_Perms_Map::load_perm_map_fileDlg $mainframe]
	if {$rt == 0} {
		ApolTop::configure_edit_pmap_menu_item 1<commit_msg>minor cleanup<commit_after># Copyright (C) 2001-2003 Tresys Technology, LLC
# see file 'COPYING' for use and warranty information 

# TCL/TK GUI for SE Linux policy analysis
# Requires tcl and tk 8.3+, with BWidgets 

##############################################################
# ::ApolTop
#  
# The top level GUI
##############################################################
namespace eval ApolTop {
	# All capital letters is the convention for variables defined via the Makefile.
	variable bwidget_version	""
	variable status 		""
	variable polversion 		""
	variable policy_type		""
	variable binary_policy_type	"binary"
	variable source_policy_type	"source"
	variable filename 		""
	# The following is used with opening a policy for loading all or pieces of a policy. 
	# The option defaults to 0 (or all portions of the policy).
	variable policy_open_option	0
	variable policyConf_lineno	""
	variable polstats 		""
	# The version number is defined as a magical string here. This is later configured in the make environment.
	variable gui_ver 		APOL_GUI_VERSION 
	variable copyright_date		"2001-2004"
	# install_dir is a magical string to be defined via the makefile!
	variable apol_install_dir	APOL_INSTALL_DIR
	variable recent_files
	variable num_recent_files 	0
	variable most_recent_file 	-1
	# The max # can be changed by the .apol file
	variable max_recent_files 	5
	# env array element HOME is an environment variable
	variable dot_apol_file 		"[file join "$::env(HOME)" ".apol"]"
	variable goto_line_num
	# Default GUI settings
	variable prevCursor		arrow
	# store the default background color for use when diabling widgets
	variable default_bg_color
	set default_bg_color 		[. cget -background] 
	variable text_font		""
	variable title_font		""
	variable dialog_font		""
	variable general_font		""
	variable temp_recent_files	""
	variable query_file_ext 	".qf"
	# Main window dimension defaults
        variable top_width             1000
        variable top_height            700
	
	# Top-level dialog widgets
	variable helpDlg
	set helpDlg .apol_helpDlg
	variable searchDlg
	set searchDlg .searchDlg
	variable goto_Dialog
	set goto_Dialog .goto_Dialog
	variable options_Dialog
	set options_Dialog .options_Dialog
	
	######################
	# Other global widgets
	variable mainframe
	variable textbox_policyConf
	variable searchDlg_entryBox
	variable gotoDlg_entryBox
	# Main top-level notebook widget
	variable notebook
	# Subordinate notebook widgets
	variable components_nb
	variable rules_nb
	
	# Search-related variables
	variable searchString		""
	variable case_Insensitive	0
	variable regExpr 		0
	variable srch_Direction		"down"
	variable policy_is_open		0
	
	# Notebook tab IDENTIFIERS; NOTE: We name all tabs after their related namespace qualified names.
	# We use the prefix 'Apol_' for all notebook tabnames. Note that the prefix must end with an 
	# underscore and that that tabnames may NOT have a colon.
	variable tabName_prefix		"Apol_"
	variable components_tab 	"Apol_Components"
    	variable rules_tab 		"Apol_Rules"
	variable types_tab		"Apol_Types"
	variable terules_tab		"Apol_TE"
	variable roles_tab		"Apol_Roles"
	variable rbac_tab		"Apol_RBAC"
	variable class_perms_tab	"Apol_Class_Perms"
	variable users_tab		"Apol_Users"
	variable initial_sids_tab	"Apol_Initial_SIDS"
	variable cond_bools_tab		"Apol_Cond_Bools"
	variable cond_rules_tab		"Apol_Cond_Rules"
	variable policy_conf_tab	"Apol_PolicyConf"
	variable analysis_tab		"Apol_Analysis"
	 
	variable tk_msgBox_Wait

	# "contents" indicates which aspects of the policy are included in the current opened policy file
	# indicies into this array are:
	# 	classes
	#	perms			(inlcudes common perms)
	#	types			(include attribs)
	#	te_rules		(all type enforcement rules)
	#	roles			
	#	rbac			(all role rules)
	#	users
        variable contents

	# Initialize the recent files list
	for {set i 0} {$i<$max_recent_files} {incr i} {
		set recent_files($i) ""
	}
}

proc ApolTop::is_policy_open {} {
	return $ApolTop::policy_is_open
}

proc ApolTop::get_install_dir {} {
	return $ApolTop::apol_install_dir
}

########################################################################
# ::load_perm_map_fileDlg -- 
#	- Called from Advanced menu
proc ApolTop::load_perm_map_fileDlg {} {
	variable mainframe
	set rt [Apol_Perms_Map::load_perm_map_fileDlg $mainframe]
	if {$rt == 0} {
		ApolTop::configure_edit_pmap_menu_item 1
{'fraction_non_alphanumeric': 0.10164746419726499, 'fraction_numerical': 0.007752772693011737, 'mean_word_length': 4.568345323741007, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1008023', 'n_tokens_mistral': 3068, 'n_tokens_neox': 2936, 'n_words': 951}