Indefero

Indefero Commit Details


Date:2011-05-24 19:13:50 (13 years 6 months ago)
Author:Thomas Keller
Branch:develop, feature.content-md5, feature.diff-whitespace, feature.download-md5, feature.issue-of-others, feature.issue-summary, feature.search-filter, feature.webrepos, feature.wiki-default-page, release-1.2, release-1.3
Commit:5b82efa0be040a462a2be70ad790cc53c3b4a408
Parents: 8502a36481949b11da51b126797c92c3163d1ef8
Message:Fix a couple of issues with our key parsing / validating code. - be explicit and expect only ssh-dss or ssh-rsa keys - allow any character (even line breaks and whitespace) in the optional comment, but shrink all of them to simple spaces (fixes issue 679) - test the newly uploaded key against existing keys only by the base key data, not the fully uploaded string (that might contain a changed comment line or the like) to avoid duplicates; also only check the keys of the user for duplicates, not all existing keys in the forge (if for whatever reason two user accounts share a key)

Changes:

File differences

NEWS.mdtext
77
88
99
10
1011
1112
1213
- monotone zip archive entries now all carry the revision date as mtime (issue 645)
- Timeline only displays filter options for items a user has actually access to (issue 655)
- Fix the self-link of the RSS feed (issue 666)
- Fix SSH public key parsing issues and improve the check for existing, uploaded keys (issue 679)
## Documentation
src/IDF/Form/UserAccount.php
317317
318318
319319
320
321
320
321
322
323
324
325
326
327
328
322329
323330
324331
......
337344
338345
339346
340
347
348
349
341350
342351
343352
......
367376
368377
369378
370
379
371380
372381
373382
return '';
}
if (preg_match('#^ssh\-[a-z]{3}\s\S+(\s\S+)?$#', $key)) {
$key = str_replace(array("\n", "\r"), '', $key);
$keysearch = '';
if (preg_match('#^(ssh\-(?:dss|rsa)\s+\S+)(.*)#', $key, $m)) {
$basekey = preg_replace('/\s+/', ' ', $m[1]);
$comment = trim(preg_replace('/[\r\n]/', ' ', $m[2]));
$keysearch = $basekey.'%';
$key = $basekey;
if (!empty($comment))
$key .= ' '.$comment;
if (Pluf::f('idf_strong_key_check', false)) {
}
}
}
else if (preg_match('#^\[pubkey [^\]]+\]\s*\S+\s*\[end\]$#', $key)) {
else if (preg_match('#^\[pubkey [^\]]+\]\s*(\S+)\s*\[end\]$#', $key, $m)) {
$keysearch = '%'.$m[1].'%';
if (Pluf::f('idf_strong_key_check', false)) {
// if monotone can read it, it should be valid
if ($user) {
$ruser = Pluf::factory('Pluf_User', $user);
if ($ruser->id > 0) {
$sql = new Pluf_SQL('content=%s', array($key));
$sql = new Pluf_SQL('content LIKE %s AND user=%s', array($keysearch, $ruser->id));
$keys = Pluf::factory('IDF_Key')->getList(array('filter' => $sql->gen()));
if (count($keys) > 0) {
throw new Pluf_Form_Invalid(
src/IDF/Key.php
8080
8181
8282
83
83
8484
8585
8686
if (preg_match('#^\[pubkey ([^\]]+)\]\s*(\S+)\s*\[end\]$#', $this->content, $m)) {
return array('mtn', $m[1], $m[2]);
}
else if (preg_match('#^ssh\-[a-z]{3}\s(\S+)(?:\s(\S*))?$#', $this->content, $m)) {
else if (preg_match('#^ssh\-(?:dss|rsa)\s(\S+)(?:\s(.*))?$#', $this->content, $m)) {
if (!isset($m[2])) {
$m[2] = "";
}

Archive Download the corresponding diff file

Page rendered in 0.08046s using 14 queries.