Author: bshaffer
Date: 2010-02-14 21:09:15 +0100 (Sun, 14 Feb 2010)
New Revision: 28025
Added:
plugins/csSecurityTaskExtraPlugin/branches/1.3/config/
plugins/csSecurityTaskExtraPlugin/branches/1.3/config/config_handlers.yml
Modified:
plugins/csSecurityTaskExtraPlugin/branches/1.3/lib/task/sfAppGroupSecurityTask.class.php
plugins/csSecurityTaskExtraPlugin/branches/1.3/lib/task/sfAppRouteSecurityTask.class.php
plugins/csSecurityTaskExtraPlugin/branches/1.3/lib/task/sfAppSecurityTask.class.php
plugins/csSecurityTaskExtraPlugin/branches/1.3/lib/task/sfAppUserSecurityTask.class.php
plugins/csSecurityTaskExtraPlugin/branches/1.3/lib/task/sfBaseSecurityTaskExtraTask.class.php
Log:
adds config_handlers.yml (this was causing issues with handler classes not
being set).
normalizes keyword formats.
Adds multiline credentials for better readability.
Added: plugins/csSecurityTaskExtraPlugin/branches/1.3/config/config_handlers.yml
===================================================================
--- plugins/csSecurityTaskExtraPlugin/branches/1.3/config/config_handlers.yml
(rev 0)
+++ plugins/csSecurityTaskExtraPlugin/branches/1.3/config/config_handlers.yml
2010-02-14 20:09:15 UTC (rev 28025)
@@ -0,0 +1,5 @@
+config/security.yml:
+ class: sfSecurityConfigHandler
+
+modules/*/config/security.yml:
+ class: sfSecurityConfigHandler
\ No newline at end of file
Modified:
plugins/csSecurityTaskExtraPlugin/branches/1.3/lib/task/sfAppGroupSecurityTask.class.php
===================================================================
---
plugins/csSecurityTaskExtraPlugin/branches/1.3/lib/task/sfAppGroupSecurityTask.class.php
2010-02-14 14:00:05 UTC (rev 28024)
+++
plugins/csSecurityTaskExtraPlugin/branches/1.3/lib/task/sfAppGroupSecurityTask.class.php
2010-02-14 20:09:15 UTC (rev 28025)
@@ -31,16 +31,18 @@
protected function execute($arguments = array(), $options = array())
{
+ $maxGroup = 5;
+ $maxModule = 6;
+ $maxAction = 6;
+ $maxHasAccess = 10;
+ $maxCredentials = 150;
+
+ $this->initializeSecurityTaskExtra();
$this->bootstrapSymfony($arguments['application'], $options['env'], true);
$databaseManager = new sfDatabaseManager($this->configuration);
$connection = $databaseManager->getDatabase('doctrine')->getConnection();
- $maxGroup = 5;
- $maxModule = 6;
- $maxAction = 6;
- $maxHasAccess = 10;
-
if ($arguments['group'])
{
$groups = Doctrine::getTable('sfGuardGroup')->createQuery()->where('name
= ?', $arguments['group'])->execute();
@@ -80,7 +82,7 @@
}
$hasAccess = $this->testCredentials($permissions,
$item['credentials']);
$groupAccess[$name][$i]['has_access'] = $hasAccess;
- $groupAccess[$name][$i]['has_access_string'] = $hasAccess ?
$this->formatter->format('yes', 'INFO') : $this->formatter->format('no',
'COMMENT');
+ $groupAccess[$name][$i]['has_access_string'] =
$this->formats[$hasAccess?'yes':'no'];
if (strlen($item['module']) > $maxModule)
{
$maxModule = strlen($item['module']);
@@ -106,7 +108,10 @@
{
if (!$arguments['module'] || $arguments['module'] == $item['module'])
{
- $this->log(sprintf($item['has_access'] ? $formatRow1:$formatRow2,
$this->formatter->format($count == 0 ? $group : '',$this->labelFormat),
$item['module'], $item['action'], $item['has_access_string'],
$item['credential_string']));
+ $this->log(sprintf($item['has_access'] ? $formatRow1:$formatRow2,
+ $this->formatter->format($count == 0 ? $group :
'',$this->labelFormat),
+ $item['module'], $item['action'],
$item['has_access_string'],
+
$this->formatMultilineCredentials($item['credential_string'], $maxCredentials,
$maxGroup+$maxModule+$maxAction+$maxHasAccess+4)));
$count++;
}
}
Modified:
plugins/csSecurityTaskExtraPlugin/branches/1.3/lib/task/sfAppRouteSecurityTask.class.php
===================================================================
---
plugins/csSecurityTaskExtraPlugin/branches/1.3/lib/task/sfAppRouteSecurityTask.class.php
2010-02-14 14:00:05 UTC (rev 28024)
+++
plugins/csSecurityTaskExtraPlugin/branches/1.3/lib/task/sfAppRouteSecurityTask.class.php
2010-02-14 20:09:15 UTC (rev 28025)
@@ -28,6 +28,12 @@
*/
protected function execute($arguments = array(), $options = array())
{
+ $maxName = 4;
+ $maxIsSecure = 9;
+ $maxCredentials = 150;
+
+ $this->initializeSecurityTaskExtra();
+
$this->bootstrapSymfony($arguments['application'], $options['env'], true);
$this->routes = $this->getRouting()->getRoutes();
@@ -89,7 +95,9 @@
{
if (!$arguments['module'] || $arguments['module'] == $policy['module'])
{
- $this->log(sprintf($policy['is_secure'] ? $formatRow1 : $formatRow2,
$name, $policy['is_secure_string'], $policy['credential_string']));
+ $this->log(sprintf($policy['is_secure'] ? $formatRow1 : $formatRow2,
+ $name, $policy['is_secure_string'],
+
$this->formatMultilineCredentials($policy['credential_string'],
$maxCredentials, $maxName+$maxIsSecure+2)));
}
}
}
Modified:
plugins/csSecurityTaskExtraPlugin/branches/1.3/lib/task/sfAppSecurityTask.class.php
===================================================================
---
plugins/csSecurityTaskExtraPlugin/branches/1.3/lib/task/sfAppSecurityTask.class.php
2010-02-14 14:00:05 UTC (rev 28024)
+++
plugins/csSecurityTaskExtraPlugin/branches/1.3/lib/task/sfAppSecurityTask.class.php
2010-02-14 20:09:15 UTC (rev 28025)
@@ -22,11 +22,14 @@
}
protected function execute($arguments = array(), $options = array())
- {
+ {
$maxModule = 6;
$maxAction = 6;
$maxIsSecure = 9;
+ $maxCredentials = 150;
+ $this->initializeSecurityTaskExtra();
+
$this->bootstrapSymfony($arguments['application'], $options['env'], true);
$security = $this->getSecurityArray();
@@ -60,7 +63,7 @@
{
if (!$arguments['module'] || $arguments['module'] == $item['module'])
{
- $this->log(sprintf($item['is_secure'] ? $formatRow1:$formatRow2,
$item['module'], $item['action'],
$item['is_secure']?$this->formatter->format('on', 'INFO') :
$this->formatter->format('off', 'COMMENT'), $item['credential_string']));
+ $this->log(sprintf($item['is_secure'] ? $formatRow1:$formatRow2,
$item['module'], $item['action'],
$this->formats[$item['is_secure']?'yes':'no'],
$this->formatMultilineCredentials($item['credential_string'], $maxCredentials,
$maxModule+$maxAction+$maxIsSecure+3)));
}
}
}
Modified:
plugins/csSecurityTaskExtraPlugin/branches/1.3/lib/task/sfAppUserSecurityTask.class.php
===================================================================
---
plugins/csSecurityTaskExtraPlugin/branches/1.3/lib/task/sfAppUserSecurityTask.class.php
2010-02-14 14:00:05 UTC (rev 28024)
+++
plugins/csSecurityTaskExtraPlugin/branches/1.3/lib/task/sfAppUserSecurityTask.class.php
2010-02-14 20:09:15 UTC (rev 28025)
@@ -31,15 +31,19 @@
protected function execute($arguments = array(), $options = array())
{
+ $maxUsername = 8;
+ $maxModule = 6;
+ $maxAction = 6;
+ $maxHasAccess = 10;
+ $maxCredentials = 150;
+
+ $this->initializeSecurityTaskExtra();
+
$this->bootstrapSymfony($arguments['application'], $options['env'], true);
$databaseManager = new sfDatabaseManager($this->configuration);
$connection = $databaseManager->getDatabase('doctrine')->getConnection();
- $maxUsername = 8;
- $maxModule = 6;
- $maxAction = 6;
- $maxHasAccess = 10;
if ($arguments['user'])
{
@@ -81,7 +85,7 @@
}
$hasAccess = $user['is_super_admin'] ||
$this->testCredentials($permissions, $item['credentials']);
$userAccess[$name][$i]['has_access'] = $hasAccess;
- $userAccess[$name][$i]['has_access_string'] = $hasAccess ?
$this->formatter->format('yes', 'INFO') : $this->formatter->format('no',
'COMMENT');
+ $userAccess[$name][$i]['has_access_string'] =
$this->formats[$hasAccess?'yes':'no'];
if (strlen($item['module']) > $maxModule)
{
@@ -107,7 +111,11 @@
{
if (!$arguments['module'] || $arguments['module'] == $item['module'])
{
- $this->log(sprintf($item['has_access'] ? $formatRow1:$formatRow2,
$this->formatter->format($count == 0 ? $name:'', $this->labelFormat),
$item['module'], $item['action'], $item['has_access_string'],
$item['credential_string']));
+ $this->log(sprintf($item['has_access'] ? $formatRow1:$formatRow2,
+ $this->formatter->format($count == 0 ? $name:'',
$this->labelFormat),
+ $item['module'], $item['action'],
$item['has_access_string'],
+
$this->formatMultilineCredentials($item['credential_string'], $maxCredentials,
$maxUsername+$maxModule+$maxAction+$maxHasAccess+4)
+ ));
$count++;
}
}
Modified:
plugins/csSecurityTaskExtraPlugin/branches/1.3/lib/task/sfBaseSecurityTaskExtraTask.class.php
===================================================================
---
plugins/csSecurityTaskExtraPlugin/branches/1.3/lib/task/sfBaseSecurityTaskExtraTask.class.php
2010-02-14 14:00:05 UTC (rev 28024)
+++
plugins/csSecurityTaskExtraPlugin/branches/1.3/lib/task/sfBaseSecurityTaskExtraTask.class.php
2010-02-14 20:09:15 UTC (rev 28025)
@@ -4,6 +4,19 @@
{
protected $labelFormat = array('fg' => 'white', 'bold' => true);
+ protected function initializeSecurityTaskExtra()
+ {
+ $this->formats = array(
+ 'left_parenthesis' => $this->formatter->format("(", 'COMMENT'),
+ 'right_parenthesis' => $this->formatter->format(")", 'COMMENT'),
+ 'and' => $this->formatter->format(' AND ', 'INFO'),
+ 'or' => $this->formatter->format(' OR ', 'INFO'),
+ 'none' => $this->formatter->format('none', 'COMMENT'),
+ 'yes' => $this->formatter->format('yes', 'INFO'),
+ 'no' => $this->formatter->format('no', 'COMMENT'),
+ );
+ }
+
protected function bootstrapSymfony($app, $env, $debug = true)
{
$configuration = ProjectConfiguration::getApplicationConfiguration($app,
$env, $debug);
@@ -36,9 +49,9 @@
'action' => 'all',
'is_secure' =>
$this->appSecurity['is_secure'],
'credentials' =>
isset($this->appSecurity['credentials']) ? $this->appSecurity['credentials'] :
array(),
- 'credential_string' =>
isset($this->appSecurity['credentials']) ?
$this->formatCredentials($this->appSecurity['credentials']) :
$this->formatter->format('none', 'COMMENT'));
+ 'credential_string' =>
isset($this->appSecurity['credentials']) ?
$this->formatCredentials($this->appSecurity['credentials']) :
$this->formats['none']);
- $this->appSecurity['is_secure_string'] = $this->appSecurity['is_secure'] ?
$this->formatter->format('yes', 'INFO') : $this->formatter->format('no',
'COMMENT');
+ $this->appSecurity['is_secure_string'] = $this->appSecurity['is_secure'] ?
$this->formats['yes'] : $this->formats['no'];
$files =
glob(sfConfig::get('sf_app_dir').'/modules/*/config/security.yml');
$security = array('global-defaut' => $this->appSecurity);
@@ -79,9 +92,9 @@
$policy['credentials'] = array();
}
- $policy['is_secure_string'] = $policy['is_secure'] ?
$this->formatter->format('yes', 'INFO') : $this->formatter->format('no',
'COMMENT');
+ $policy['is_secure_string'] = $policy['is_secure'] ?
$this->formats['yes'] : $this->formats['no'];
- $policy['credential_string'] = $policy['credentials'] ?
$this->formatCredentials($policy['credentials']) :
$this->formatter->format('none', 'COMMENT');
+ $policy['credential_string'] = $policy['credentials'] ?
$this->formatCredentials($policy['credentials']) : $this->formats['none'];
$security[$key] = $policy;
}
@@ -119,16 +132,39 @@
$formattedString = is_array($credential) ?
$this->formatCredentials($credential, !$and) : $credential;
if (is_array($credential) && count($credentials) > 1)
{
- $formattedString = $this->formatter->format("(",
'COMMENT').$formattedString.$this->formatter->format(")", 'COMMENT');
+ $formattedString =
$this->formats['left_parenthesis'].$formattedString.$this->formats['right_parenthesis'];
}
$formattedCredentials[] = $formattedString;
}
- return implode($this->formatter->format($and ? ' AND ' : ' OR ',
'INFO'), $formattedCredentials);
+ return implode($and ? $this->formats['and'] : $this->formats['or'],
$formattedCredentials);
}
return $credentials;
}
+ public function formatMultilineCredentials($credentials, $maxCredentials,
$numSpaces)
+ {
+ if (strlen($credentials) > $maxCredentials)
+ {
+ $line = substr($credentials, 0, $maxCredentials);
+ $split = max(strrpos($line, $this->formats['left_parenthesis']),
+ strrpos($line, $this->formats['right_parenthesis']) +
strlen($this->formats['right_parenthesis']));
+ if ($split == 0)
+ {
+ $split = max(strrpos($line, $this->formats['and']) +
strlen($this->formats['and']),
+ strrpos($line, $this->formats['or']) +
strlen($this->formats['or']),
+ strrpos($line, ' ') + 1);
+ if ($split == 0)
+ {
+ return trim($credentials);
+ }
+ }
+ $append = $this->formatMultilineCredentials(substr($credentials,
$split), $maxCredentials, $numSpaces);
+ $credentials = substr($credentials, 0, $split)."\n".str_repeat(' ',
$numSpaces). $append;
+ }
+ return trim($credentials);
+ }
+
protected function hasCredential($credentials, $useAnd = true)
{
if (!is_array($credentials))
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.