Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
telegraf-nftables
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Due to inactivity, this project is scheduled to be deleted on 2035-04-24.
Why is this scheduled?
Show more breadcrumbs
vqgroup
telegraf-nftables
Commits
2fbcb5c6
Commit
2fbcb5c6
authored
9 years ago
by
Thomas Menard
Committed by
Cameron Sparr
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix postgresql password exposure in metrics
Fix the password exposure in the metrics or tags. closes #821 closes #845
parent
a4d60d97
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CHANGELOG.md
+1
-0
1 addition, 0 deletions
CHANGELOG.md
plugins/inputs/postgresql/postgresql.go
+31
-6
31 additions, 6 deletions
plugins/inputs/postgresql/postgresql.go
with
32 additions
and
6 deletions
CHANGELOG.md
+
1
−
0
View file @
2fbcb5c6
...
...
@@ -29,6 +29,7 @@
-
[
#713
](
https://github.com/influxdata/telegraf/issues/713
)
: packaging: insecure permissions error on log directory
-
[
#816
](
https://github.com/influxdata/telegraf/issues/816
)
: Fix phpfpm panic if fcgi endpoint unreachable.
-
[
#828
](
https://github.com/influxdata/telegraf/issues/828
)
: fix net_response plugin overwriting host tag.
-
[
#821
](
https://github.com/influxdata/telegraf/issues/821
)
: Remove postgres password from server tag. Thanks @menardorama!
## v0.10.4.1
...
...
This diff is collapsed.
Click to expand it.
plugins/inputs/postgresql/postgresql.go
+
31
−
6
View file @
2fbcb5c6
...
...
@@ -4,20 +4,22 @@ import (
"bytes"
"database/sql"
"fmt"
"regexp"
"sort"
"strings"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins/inputs"
_
"github.com/lib/pq"
"github.com/lib/pq"
)
type
Postgresql
struct
{
Address
string
Databases
[]
string
OrderedColumns
[]
string
AllColumns
[]
string
Address
string
Databases
[]
string
OrderedColumns
[]
string
AllColumns
[]
string
sanitizedAddress
string
}
var
ignoredColumns
=
map
[
string
]
bool
{
"datid"
:
true
,
"datname"
:
true
,
"stats_reset"
:
true
}
...
...
@@ -133,6 +135,23 @@ type scanner interface {
Scan
(
dest
...
interface
{})
error
}
var
passwordKVMatcher
,
_
=
regexp
.
Compile
(
"password=
\\
S+ ?"
)
func
(
p
*
Postgresql
)
SanitizedAddress
()
(
_
string
,
err
error
)
{
var
canonicalizedAddress
string
if
strings
.
HasPrefix
(
p
.
Address
,
"postgres://"
)
||
strings
.
HasPrefix
(
p
.
Address
,
"postgresql://"
)
{
canonicalizedAddress
,
err
=
pq
.
ParseURL
(
p
.
Address
)
if
err
!=
nil
{
return
p
.
sanitizedAddress
,
err
}
}
else
{
canonicalizedAddress
=
p
.
Address
}
p
.
sanitizedAddress
=
passwordKVMatcher
.
ReplaceAllString
(
canonicalizedAddress
,
""
)
return
p
.
sanitizedAddress
,
err
}
func
(
p
*
Postgresql
)
accRow
(
row
scanner
,
acc
telegraf
.
Accumulator
)
error
{
var
columnVars
[]
interface
{}
var
dbname
bytes
.
Buffer
...
...
@@ -165,7 +184,13 @@ func (p *Postgresql) accRow(row scanner, acc telegraf.Accumulator) error {
dbname
.
WriteString
(
"postgres"
)
}
tags
:=
map
[
string
]
string
{
"server"
:
p
.
Address
,
"db"
:
dbname
.
String
()}
var
tagAddress
string
tagAddress
,
err
=
p
.
SanitizedAddress
()
if
err
!=
nil
{
return
err
}
tags
:=
map
[
string
]
string
{
"server"
:
tagAddress
,
"db"
:
dbname
.
String
()}
fields
:=
make
(
map
[
string
]
interface
{})
for
col
,
val
:=
range
columnMap
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment