<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
#
# Author: <<EMAIL>>
#

##############################################################
# ::Apol_Initial_SIDS
#  
# The Initial SIDS page
##############################################################
namespace eval Apol_Initial_SIDS {
	# opts(opt), where opt =
	variable opts
	set opts(user)			""
	set opts(role)			""
	set opts(type)			""
	variable attribute_selected	""
	variable user_cb_value		0
	variable role_cb_value		0
	variable type_cb_value		0
	variable attribute_cb_value	0
	variable sids_list 		""
	
	# Global Widgets
	variable resultsbox
	variable init_sids_listbox
	variable user_combo_box
	variable role_combo_box
	variable type_combo_box
	variable attribute_combo_box
	variable cb_attrib
}

##############################################################
# ::search
#  	- Search text widget for a string
# 
proc Apol_Initial_SIDS::search { str case_Insensitive regExpr srch_Direction } {
	variable resultsbox
	
	ApolTop::textSearch $resultsbox $str $case_Insensitive $regExpr $srch_Direction
	return 0
}

# ----------------------------------------------------------------------------------------
#  Command Apol_Initial_SIDS::set_Focus_to_Text
#
#  Description: 
# ----------------------------------------------------------------------------------------
proc Apol_Initial_SIDS::set_Focus_to_Text {} {
	focus $Apol_Initial_SIDS::resultsbox
	return 0
}

# ------------------------------------------------------------------------------
#  Command Apol_Initial_SIDS::searchSIDs
# ------------------------------------------------------------------------------
proc Apol_Initial_SIDS::searchSIDs {} {
	variable opts
	
	if {$Apol_Initial_SIDS::user_cb_value && $opts(user) == ""} {
		tk_messageBox -icon error -type ok -title "Error" -message "You must provide a user."
		return -1
	} 
	if {$Apol_Initial_SIDS::role_cb_value && $opts(role) == ""} {
		tk_messageBox -icon error -type ok -title "Error" -message "You must provide a role."
		return -1
	} 
	if {$Apol_Initial_SIDS::type_cb_value && $opts(type) == ""} {
		tk_messageBox -icon error -type ok -title "Error" -message "You must provide a type."
		return -1
	} 
	
	set rt [catch {set results [apol_SearchInitialSIDs $opts(user) $opts(role) $opts(type)]} err]
	if {$rt != 0} {	
		tk_messageBox -icon error -type ok -title "Error" -message "$err"
		return -1
	} else {
		$Apol_Initial_SIDS::resultsbox configure -state normal
		$Apol_Initial_SIDS::resultsbox delete 0.0 end
		$Apol_Initial_SIDS::resultsbox insert end $results
		ApolTop::makeTextBoxReadOnly $Apol_Initial_SIDS::resultsbox 
	}

	return 0
}

# ------------------------------------------------------------------------------
#  Command Apol_Initial_SIDS::open
# ------------------------------------------------------------------------------
proc Apol_Initial_SIDS::open { } {
	variable sids_list
	
	set sids_list [apol_GetNames initial_sids] 
	set sids_list [lsort $sids_list]
	$Apol_Initial_SIDS::user_combo_box configure -values $Apol_Users::users_list
	$Apol_Initial_SIDS::role_combo_box configure -values $Apol_Roles::role_list
	$Apol_Initial_SIDS::type_combo_box configure -values $ApolTypes::typelist
	$Apol_Initial_SIDS::attribute_combo_box configure -values $ApolTypes::attriblist
	
	Apol_Initial_SIDS::enable_comboBox $Apol_Initial_SIDS::user_cb_value $Apol_Initial_SIDS::user_combo_box
	Apol_Initial_SIDS::enable_comboBox $Apol_Initial_SIDS::role_cb_value $Apol_Initial_SIDS::role_combo_box
	Apol_Initial_SIDS::enable_comboBox $Apol_Initial_SIDS::type_cb_value $Apol_Initial_SIDS::type_combo_box
	Apol_Initial_SIDS::enable_comboBox $Apol_Initial_SIDS::attribute_cb_value $Apol_Initial_SIDS::attribute_combo_box
	$Apol_Initial_SIDS::cb_attrib configure -state disabled<commit_msg>Fix to search initial sids in tcl code.<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
#
# Author: <<EMAIL>>
#

##############################################################
# ::Apol_Initial_SIDS
#  
# The Initial SIDS page
##############################################################
namespace eval Apol_Initial_SIDS {
	# opts(opt), where opt =
	variable opts
	set opts(user)			""
	set opts(role)			""
	set opts(type)			""
	variable attribute_selected	""
	variable user_cb_value		0
	variable role_cb_value		0
	variable type_cb_value		0
	variable attribute_cb_value	0
	variable sids_list 		""
	
	# Global Widgets
	variable resultsbox
	variable init_sids_listbox
	variable user_combo_box
	variable role_combo_box
	variable type_combo_box
	variable attribute_combo_box
	variable cb_attrib
}

##############################################################
# ::search
#  	- Search text widget for a string
# 
proc Apol_Initial_SIDS::search { str case_Insensitive regExpr srch_Direction } {
	variable resultsbox
	
	ApolTop::textSearch $resultsbox $str $case_Insensitive $regExpr $srch_Direction
	return 0
}

# ----------------------------------------------------------------------------------------
#  Command Apol_Initial_SIDS::set_Focus_to_Text
#
#  Description: 
# ----------------------------------------------------------------------------------------
proc Apol_Initial_SIDS::set_Focus_to_Text {} {
	focus $Apol_Initial_SIDS::resultsbox
	return 0
}

# ------------------------------------------------------------------------------
#  Command Apol_Initial_SIDS::searchSIDs
# ------------------------------------------------------------------------------
proc Apol_Initial_SIDS::searchSIDs {} {
	variable opts
	
	set user ""
	set role ""
	set type ""
	if {$Apol_Initial_SIDS::user_cb_value && $opts(user) == ""} {
		tk_messageBox -icon error -type ok -title "Error" -message "You must provide a user."
		return -1
	} elseif {$Apol_Initial_SIDS::user_cb_value} {
		set user $opts(user)
	}
	if {$Apol_Initial_SIDS::role_cb_value && $opts(role) == ""} {
		tk_messageBox -icon error -type ok -title "Error" -message "You must provide a role."
		return -1
	} elseif {$Apol_Initial_SIDS::role_cb_value} {
		set role $opts(role)
	}
	if {$Apol_Initial_SIDS::type_cb_value && $opts(type) == ""} {
		tk_messageBox -icon error -type ok -title "Error" -message "You must provide a type."
		return -1
	} elseif {$Apol_Initial_SIDS::type_cb_value} {
		set type $opts(type)
	}
	
	set rt [catch {set results [apol_SearchInitialSIDs $user $role $type]} err]
	if {$rt != 0} {	
		tk_messageBox -icon error -type ok -title "Error" -message "$err"
		return -1
	} else {
		$Apol_Initial_SIDS::resultsbox configure -state normal
		$Apol_Initial_SIDS::resultsbox delete 0.0 end
		$Apol_Initial_SIDS::resultsbox insert end $results
		ApolTop::makeTextBoxReadOnly $Apol_Initial_SIDS::resultsbox 
	}

	return 0
}

# ------------------------------------------------------------------------------
#  Command Apol_Initial_SIDS::open
# ------------------------------------------------------------------------------
proc Apol_Initial_SIDS::open { } {
	variable sids_list
	
	set sids_list [apol_GetNames initial_sids] 
	set sids_list [lsort $sids_list]
	$Apol_Initial_SIDS::user_combo_box configure -values $Apol_Users::users_list
	$Apol_Initial_SIDS::role_combo_box configure -values $Apol_Roles::role_list
	$Apol_Initial_SIDS::type_combo_box configure -values $ApolTypes::typelist
	$Apol_Initial_SIDS::attribute_combo_box configure -values $ApolTypes::attriblist
	
	Apol_Initial_SIDS::enable_comboBox $Apol_Initial_SIDS::user_cb_value $Apol_Initial_SIDS::user_combo_box
	Apol_Initial_SIDS::enable_comboBox $Apol_Initial_SIDS::role_cb_value $Apol_Initial_SIDS::role_combo_box
	Apol_Initial_SIDS::enable_comboBox $Apol_Initial_SIDS::type_cb_value $Apol_Initial_SIDS::type_combo_box
	Apol_Initial_SIDS::enable_comboBox $Apol_Initial_SIDS::attribute_cb_value $Apol_Initial_SIDS::attribute_combo_box
	$Apol_Initial_SIDS::cb_attrib configure -state disabled
{'fraction_non_alphanumeric': 0.24669549104385424, 'fraction_numerical': 0.00592958616429895, 'mean_word_length': 3.043956043956044, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5196024', 'n_tokens_mistral': 2649, 'n_tokens_neox': 2532, 'n_words': 549}