<commit_before>/**
 * list global permissions and permissions on jobs a given user has
 *
 * required Scripler parameters:
 * USERNAME (String) - login of user under inverstigation
 *
 */

import hudson.model.Hudson

// extract a list permissions for a given user from a given xml fragment
xml2perms = {usr, xml ->
	xml.permission.collect {
		it.text().split(':')
	}.findAll {
		it[1] == USERNAME
	}.collect {
		it[0].replaceAll(/^[a-z.]+/, '')
	}
}

root = Hudson.instance.root

println 'Global: ' + xml2perms(usr,
	new XmlSlurper().parse(new File(root, 'config.xml')).authorizationStrategy).join(', ')

println new File(root, 'jobs').listFiles().findAll {
	it.directory
}.collect {
	new File(it, 'config.xml')
}.findAll {
	it.exists()
}.collect {
	[name: it.parentFile.name,
	perm: xml2perms(usr, new XmlSlurper().parse(it).properties.'hudson.security.AuthorizationMatrixProperty')]
}.findAll {
	it.perm
}.collect {
	"$it.name: ${it.perm.join(', ')}"
}.join('\n')
<commit_msg>fix misuse of USERNAME parameter<commit_after>/**
 * list global permissions and permissions on jobs a given user has
 *
 * required Scripler parameters:
 * USERNAME (String) - login of user under inverstigation
 *
 */

import hudson.model.Hudson

// extract a list permissions for a given user from a given xml fragment
xml2perms = {usr, xml ->
	xml.permission.collect {
		it.text().split(':')
	}.findAll {
		it[1] == usr
	}.collect {
		it[0].replaceAll(/^[a-z.]+/, '')
	}
}

root = Hudson.instance.root

println 'Global: ' + xml2perms(USERNAME,
	new XmlSlurper().parse(new File(root, 'config.xml')).authorizationStrategy).join(', ')

println new File(root, 'jobs').listFiles().findAll {
	it.directory
}.collect {
	new File(it, 'config.xml')
}.findAll {
	it.exists()
}.collect {
	[name: it.parentFile.name,
	perm: xml2perms(USERNAME,
		new XmlSlurper().parse(it).properties.'hudson.security.AuthorizationMatrixProperty')]
}.findAll {
	it.perm
}.collect {
	"$it.name: ${it.perm.join(', ')}"
}.join('\n')

{'fraction_non_alphanumeric': 0.17457114026236126, 'fraction_numerical': 0.005045408678102927, 'mean_word_length': 4.259946949602122, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 16}, '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': '2395076', 'n_tokens_mistral': 714, 'n_tokens_neox': 697, 'n_words': 164}