Skip to content

Commit 0a150fe

Browse files
committed
Initial import
1 parent 3c7ce8e commit 0a150fe

File tree

13 files changed

+656
-0
lines changed

13 files changed

+656
-0
lines changed

.codecov.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
coverage:
2+
status:
3+
project: yes
4+
5+
comment:
6+
layout: "diff"
7+
behavior: once
8+
require_changes: true
9+
require_base: no
10+
require_head: yes
11+
branches: null

.php_cs.dist

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
$finder = PhpCsFixer\Finder::create()
3+
->in([
4+
__DIR__ . '/lib',
5+
__DIR__ . '/tests',
6+
])
7+
;
8+
return PhpCsFixer\Config::create()
9+
->setRules([
10+
'@PSR2' => true,
11+
'@PSR4' => true,
12+
'@PSR5' => true,
13+
])
14+
->setFinder($finder)
15+
;

.travis.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
sudo: required
2+
3+
language: php
4+
5+
php:
6+
- 5.6
7+
- 7.0
8+
- 7.1
9+
- 7.2
10+
- 7.3
11+
12+
env:
13+
- SIMPLESAMLPHP_VERSION=1.17.*
14+
15+
before_script:
16+
- composer require "simplesamlphp/simplesamlphp:${SIMPLESAMLPHP_VERSION}" --no-update
17+
- composer update --no-interaction
18+
- if [[ "$TRAVIS_PHP_VERSION" == "7.3" ]]; then composer require --dev vimeo/psalm:1.1.9; fi
19+
20+
script:
21+
- bin/check-syntax.sh
22+
- if [[ "$TRAVIS_PHP_VERSION" == "5.6" ]]; then php vendor/phpunit/phpunit/phpunit; else php vendor/phpunit/phpunit/phpunit --no-coverage; fi
23+
- if [[ "$TRAVIS_PHP_VERSION" == "7.3" ]]; then vendor/bin/psalm; fi
24+
25+
after_success:
26+
# Codecov, need to edit bash uploader for incorrect TRAVIS_PYTHON_VERSION environment variable matching, at least until codecov/codecov-bash#133 is resolved
27+
- curl -s https://codecov.io/bash > .codecov
28+
- sed -i -e 's/TRAVIS_.*_VERSION/^TRAVIS_.*_VERSION=/' .codecov
29+
- chmod +x .codecov
30+
- if [[ $TRAVIS_PHP_VERSION == "5.6" ]]; then ./.codecov -X gcov; fi
31+
# - if [[ "$TRAVIS_PHP_VERSION" == "5.6" ]]; then bash <(curl -s https://codecov.io/bash); fi

bin/check-syntax.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
3+
PHP='/usr/bin/env php'
4+
RETURN=0
5+
6+
# check PHP files
7+
for FILE in `find lib tests -name "*.php"`; do
8+
$PHP -l $FILE > /dev/null 2>&1
9+
if [ $? -ne 0 ]; then
10+
echo "Syntax check failed for ${FILE}"
11+
RETURN=`expr ${RETURN} + 1`
12+
fi
13+
done
14+
15+
exit $RETURN

bin/loganalyzer.php

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
// This is the base directory of the SimpleSAMLphp installation
5+
$baseDir = dirname(dirname(dirname(dirname(__FILE__))));
6+
7+
// Add library autoloader.
8+
require_once($baseDir.'/lib/_autoload.php');
9+
10+
// Initialize the configuration.
11+
$configdir = \SimpleSAML\Utils\Config::getConfigDir();
12+
\SimpleSAML\Configuration::setConfigDir($configdir);
13+
\SimpleSAML\Utils\Time::initTimezone();
14+
15+
$progName = array_shift($argv);
16+
$debug = false;
17+
$dryrun = false;
18+
19+
foreach ($argv as $a) {
20+
if (strlen($a) === 0) {
21+
continue;
22+
}
23+
if (strpos($a, '=') !== false) {
24+
$p = strpos($a, '=');
25+
$v = substr($a, $p + 1);
26+
$a = substr($a, 0, $p);
27+
} else {
28+
$v = null;
29+
}
30+
31+
// Map short options to long options.
32+
$shortOptMap = ['-d' => '--debug'];
33+
if (array_key_exists($a, $shortOptMap)) {
34+
$a = $shortOptMap[$a];
35+
}
36+
switch ($a) {
37+
case '--help':
38+
printHelp();
39+
exit(0);
40+
case '--debug':
41+
$debug = true;
42+
break;
43+
case '--dry-run':
44+
$dryrun = true;
45+
break;
46+
default:
47+
echo 'Unknown option: '.$a."\n";
48+
echo 'Please run `'.$progName.' --help` for usage information.'."\n";
49+
exit(1);
50+
}
51+
}
52+
53+
$aggregator = new \SimpleSAML\Module\statistics\Aggregator(true);
54+
$aggregator->dumpConfig();
55+
$aggregator->debugInfo();
56+
$results = $aggregator->aggregate($debug);
57+
$aggregator->debugInfo();
58+
59+
if (!$dryrun) {
60+
$aggregator->store($results);
61+
}
62+
63+
foreach ($results as $slot => $val) {
64+
foreach ($val as $sp => $no) {
65+
echo $sp." ".count($no)." - ";
66+
}
67+
echo "\n";
68+
}
69+
70+
71+
/**
72+
* This function prints the help output.
73+
* @return void
74+
*/
75+
function printHelp()
76+
{
77+
global $progName;
78+
79+
echo <<<END
80+
Usage: $progName [options]
81+
82+
This program parses and aggregates SimpleSAMLphp log files.
83+
84+
Options:
85+
-d, --debug Used when configuring the log file syntax. See doc.
86+
--dry-run Aggregate but do not store the results.
87+
END;
88+
}

bin/logcleaner.php

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
// This is the base directory of the SimpleSAMLphp installation
5+
$baseDir = dirname(dirname(dirname(dirname(__FILE__))));
6+
7+
// Add library autoloader.
8+
require_once($baseDir.'/lib/_autoload.php');
9+
10+
// Initialize the configuration.
11+
$configdir = \SimpleSAML\Utils\Config::getConfigDir();
12+
\SimpleSAML\Configuration::setConfigDir($configdir);
13+
14+
$progName = array_shift($argv);
15+
$debug = false;
16+
$dryrun = false;
17+
$output = '/tmp/simplesamlphp-new.log';
18+
$infile = null;
19+
20+
foreach ($argv as $a) {
21+
if (strlen($a) === 0) {
22+
continue;
23+
}
24+
if (strpos($a, '=') !== false) {
25+
$p = strpos($a, '=');
26+
$v = substr($a, $p + 1);
27+
$a = substr($a, 0, $p);
28+
} else {
29+
$v = null;
30+
}
31+
32+
// Map short options to long options.
33+
$shortOptMap = ['-d' => '--debug'];
34+
if (array_key_exists($a, $shortOptMap)) {
35+
$a = $shortOptMap[$a];
36+
}
37+
38+
switch ($a) {
39+
case '--help':
40+
printHelp();
41+
exit(0);
42+
case '--debug':
43+
$debug = true;
44+
break;
45+
case '--dry-run':
46+
$dryrun = true;
47+
break;
48+
case '--infile':
49+
$infile = $v;
50+
break;
51+
case '--outfile':
52+
$output = $v;
53+
break;
54+
default:
55+
echo 'Unknown option: '.$a."\n";
56+
echo 'Please run `'.$progName.' --help` for usage information.'."\n";
57+
exit(1);
58+
}
59+
}
60+
61+
$cleaner = new \SimpleSAML\Module\statistics\LogCleaner($infile);
62+
$cleaner->dumpConfig();
63+
$todelete = $cleaner->clean($debug);
64+
65+
echo "Cleaning these trackIDs: ".join(', ', $todelete)."\n";
66+
67+
if (!$dryrun) {
68+
$cleaner->store($todelete, $output);
69+
}
70+
71+
/**
72+
* This function prints the help output.
73+
* @return void
74+
*/
75+
function printHelp()
76+
{
77+
global $progName;
78+
79+
echo <<<END
80+
Usage: $progName [options]
81+
82+
This program cleans logs. This script is experimental. Do not run it unless you have talked to Andreas about it.
83+
The script deletes log lines related to sessions that produce more than 200 lines.
84+
85+
Options:
86+
-d, --debug Used when configuring the log file syntax. See doc.
87+
--dry-run Aggregate but do not store the results.
88+
--infile File input.
89+
--outfile File to output the results.
90+
91+
END;
92+
}

composer.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "simplesamlphp/simplesamlphp-module-sqlauth",
3+
"description": "This is a authentication module for authenticating a user against a SQL database",
4+
"type": "simplesamlphp-module",
5+
"keywords": ["simplesamlphp", "sqlauth"],
6+
"license": "LGPL-3.0-or-later",
7+
"authors": [
8+
{
9+
"name": "Olav Morken",
10+
"email": "[email protected]"
11+
}
12+
],
13+
"config": {
14+
"preferred-install": {
15+
"simplesamlphp/simplesamlphp": "source",
16+
"*": "dist"
17+
}
18+
},
19+
"autoload": {
20+
"psr-4": {
21+
"SimpleSAML\\Module\\sqlauth\\": "lib/"
22+
}
23+
},
24+
"autoload-dev": {
25+
"psr-4": {
26+
"SimpleSAML\\Test\\Utils\\": "vendor/simplesamlphp/simplesamlphp/tests/Utils"
27+
}
28+
},
29+
"require": {
30+
"php": ">=5.6",
31+
"simplesamlphp/composer-module-installer": "~1.1"
32+
},
33+
"require-dev": {
34+
"phpunit/phpunit": "~5.7",
35+
"simplesamlphp/simplesamlphp": "^1.17",
36+
"webmozart/assert": "^1.4"
37+
},
38+
"support": {
39+
"issues": "https://github.com/tvdijen/simplesamlphp-module-sqlauth/issues",
40+
"source": "https://github.com/tvdijen/simplesamlphp-module-sqlauth"
41+
}
42+
}

default-enable

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This file indicates that the default state of this module
2+
is enabled. To disable, create a file named disable in the
3+
same directory as this file.

0 commit comments

Comments
 (0)