Commit d813bd6
committed
fix(ingestion): protect all connectors from scheme-prefixed hostPort by stripping in model_post_init
Addresses gitar-bot review feedback on PR open-metadata#27191: moving strip_hostport_scheme
to get_connection_url_common left several connectors that parse hostPort manually
still vulnerable to the original crash (open-metadata#24348):
- cassandra/connection.py: host, port = connection.hostPort.split(':')
- db2/connection.py: connection.hostPort.split(':')[0]
- databricks/auth.py: connection.hostPort.split(':')[0]
- redshift/connection.py: connection.hostPort.split(':')[0]
- microsoftfabric/connection.py: connection.hostPort.split(':')[0]
- builders.py (IAM auth): connection.hostPort.split(':')
Restore strip_hostport_scheme call to model_post_init so scheme stripping
happens at construction time for ALL *Connection classes, protecting every
downstream split site automatically.
Exclude AirflowConnection and OpenMetadataConnection via _HOSTPORT_URL_ALLOWED
since their hostPort field legitimately stores a full URL (e.g.
http://localhost:8080 and http://localhost:8585/api).
The call in get_connection_url_common is kept for defence-in-depth; it is
idempotent because strip_hostport_scheme short-circuits when '://' is absent.
Add three new unit tests to test_connection_builders.py covering:
- URL scheme stripping at model construction
- ValueError raised for invalid port at construction time
- URL-allowed connections are not stripped1 parent 96428c1 commit d813bd6
2 files changed
Lines changed: 94 additions & 5 deletions
File tree
- ingestion
- src/metadata/ingestion/models
- tests/unit
Lines changed: 29 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
125 | 132 | | |
126 | 133 | | |
127 | 134 | | |
| |||
134 | 141 | | |
135 | 142 | | |
136 | 143 | | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
137 | 149 | | |
138 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
139 | 168 | | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | 169 | | |
146 | 170 | | |
147 | 171 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
22 | 25 | | |
23 | 26 | | |
24 | 27 | | |
25 | 28 | | |
26 | 29 | | |
| 30 | + | |
27 | 31 | | |
28 | 32 | | |
29 | 33 | | |
| |||
79 | 83 | | |
80 | 84 | | |
81 | 85 | | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
0 commit comments