Skip to content

Commit

Permalink
Update privateNetworkLinkRegex to protect against values starting w…
Browse files Browse the repository at this point in the history
…ith `/projects...` (#6650) (#12749)

* Update regexp for resources to start with `^projects`, to avoid confusion

* Revert regex changes

* Update `private_network` regex to match fully-qualified or relative urls

* Revert regex changes

* Revert regex changes

Signed-off-by: Modular Magician <magic-modules@google.com>

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician committed Oct 10, 2022
1 parent 89498f7 commit b5b027b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/6650.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:note
Updated regex validation of resource ids to prevent leading slashes
```
3 changes: 2 additions & 1 deletion google/resource_sql_database_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import (
sqladmin "google.golang.org/api/sqladmin/v1beta4"
)

const privateNetworkLinkRegex = "projects/(" + ProjectRegex + ")/global/networks/((?:[a-z](?:[-a-z0-9]*[a-z0-9])?))$"
// Match fully-qualified or relative URLs
const privateNetworkLinkRegex = "^(?:http(?:s)?://.+/)?projects/(" + ProjectRegex + ")/global/networks/((?:[a-z](?:[-a-z0-9]*[a-z0-9])?))$"

var sqlDatabaseAuthorizedNetWorkSchemaElem *schema.Resource = &schema.Resource{
Schema: map[string]*schema.Schema{
Expand Down

0 comments on commit b5b027b

Please sign in to comment.