aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2023-01-11 23:27:14 +0100
committerGravatar GitHub <noreply@github.com> 2023-01-11 23:27:14 +0100
commit075cf4c800063e3cc65c3d41a9c23222e8ebb554 (patch)
tree6fb7d9c66fdbafea83f160c9043d9fd688844c1b /lib
parentc75baefe40952e6ae80aa8570c0acfc9baf7d997 (diff)
API avoid logging passwords (#5001)
* API avoid logging passwords * Strip passwords and tokens from API logs * Only log failed requests information when in debug mode * Remove debug SHA * Clean also Apache logs * Better comments * Redact also token parameters * shfmt * Simplify whitespace * redacted
Diffstat (limited to 'lib')
-rw-r--r--lib/lib_rss.php25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/lib_rss.php b/lib/lib_rss.php
index d0e819d98..cbdfff773 100644
--- a/lib/lib_rss.php
+++ b/lib/lib_rss.php
@@ -224,6 +224,31 @@ function html_only_entity_decode($text): string {
}
/**
+ * Remove passwords in FreshRSS logs.
+ * See also ../cli/sensitive-log.sh for Web server logs.
+ * @param array<string,mixed>|string $log
+ * @return array<string,mixed>|string
+ */
+function sensitive_log($log) {
+ if (is_array($log)) {
+ foreach ($log as $k => $v) {
+ if (in_array($k, ['api_key', 'Passwd', 'T'])) {
+ $log[$k] = '██';
+ } else {
+ $log[$k] = sensitive_log($v);
+ }
+ }
+ } elseif (is_string($log)) {
+ $log = preg_replace([
+ '/\b(auth=.*?\/)[^&]+/i',
+ '/\b(Passwd=)[^&]+/i',
+ '/\b(Authorization)[^&]+/i',
+ ], '$1█', $log);
+ }
+ return $log;
+}
+
+/**
* @param array<string,mixed> $attributes
*/
function customSimplePie($attributes = array()): SimplePie {