Commit 7efda8d
committed
🐛 postgres: clean parse guard, dedupe DSN password, canonicalise include paths
Round of fixes from the PR #7927 review:
* postgresql.conf parser canonicalises `path` via `filepath.Clean`
before checking the cycle guard so equivalent spellings (`./foo`,
`bar/../foo`, `foo`) collapse to the same key and self-referential
include loops are caught.
* `mqlPostgresqlConf.parse()` now guards on a dedicated `parsed bool`
in the Internal struct instead of overloading `Params.State ==
StateIsSet`. The old guard never matched the
`StateIsSet|StateIsNull` value set on error/empty, so a transient
failure would re-parse on every field access.
* postgres provider: drop the leftover `var _ = errors.New` stubs in
`resources/postgres.go` and `connection/connection.go` (and the
unused `errors` import in connection). `errors.New` is used for
real elsewhere; the suppression was unnecessary.
* Replace the hand-rolled `strFromInt` helper with `strconv.Itoa` in
`postgres.go` and remove the dead function.
The libpq key=value branch of `mergePasswordIntoDSN` already strips
existing `password=` tokens before appending the merged one, and the
URL branch uses `url.UserPassword(...)` which replaces (not appends)
the password — both are correct, no change needed there. The
`hbaRules` fallback still string-matches on `"rule_number"` rather
than type-asserting to a pgx error; refactoring that to inspect the
SQLSTATE on the pgx error is left as a follow-up since we don't
currently import a typed error interface in this file.
Signed-off-by: Tim Smith <tsmith84@gmail.com>1 parent 441da35 commit 7efda8d
4 files changed
Lines changed: 22 additions & 38 deletions
File tree
- providers
- os/resources
- postgresql
- postgres
- connection
- resources
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
50 | 56 | | |
51 | 57 | | |
52 | 58 | | |
| |||
104 | 110 | | |
105 | 111 | | |
106 | 112 | | |
107 | | - | |
| 113 | + | |
108 | 114 | | |
109 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
110 | 120 | | |
111 | 121 | | |
112 | 122 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
57 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
58 | 62 | | |
59 | 63 | | |
60 | | - | |
| 64 | + | |
61 | 65 | | |
62 | 66 | | |
63 | 67 | | |
| |||
128 | 132 | | |
129 | 133 | | |
130 | 134 | | |
131 | | - | |
| 135 | + | |
132 | 136 | | |
133 | 137 | | |
134 | 138 | | |
| |||
149 | 153 | | |
150 | 154 | | |
151 | 155 | | |
152 | | - | |
| 156 | + | |
153 | 157 | | |
154 | 158 | | |
155 | 159 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
| |||
341 | 340 | | |
342 | 341 | | |
343 | 342 | | |
344 | | - | |
345 | | - | |
346 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | 19 | | |
23 | 20 | | |
24 | 21 | | |
| |||
808 | 805 | | |
809 | 806 | | |
810 | 807 | | |
811 | | - | |
812 | | - | |
813 | | - | |
814 | | - | |
815 | | - | |
816 | | - | |
817 | | - | |
818 | | - | |
819 | | - | |
820 | | - | |
821 | | - | |
822 | | - | |
823 | | - | |
824 | | - | |
825 | | - | |
826 | | - | |
827 | | - | |
828 | | - | |
829 | | - | |
830 | | - | |
831 | | - | |
832 | | - | |
833 | | - | |
834 | | - | |
| 808 | + | |
835 | 809 | | |
836 | | - | |
| 810 | + | |
837 | 811 | | |
838 | 812 | | |
839 | 813 | | |
| |||
0 commit comments