-
Notifications
You must be signed in to change notification settings - Fork 446
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump max length for installer URLs supplied in GitOps to 4000 charact…
…ers (#24942) For #24917. Should be worth the extra byte per row for the varchar field. # Checklist for submitter - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/Committing-Changes.md#changes-files) for more information. - [x] Added/updated tests - [x] If database migrations are included, checked table schema to confirm autoupdate - For database migrations: - [x] Checked schema for all modified table for columns that will auto-update timestamps during migration. - [x] Confirmed that updating the timestamps is acceptable, and will not cause unwanted side effects. - [x] Ensured the correct collation is explicitly set for character columns (`COLLATE utf8mb4_unicode_ci`). - [x] Manual QA for all new/changed functionality
- Loading branch information
Showing
9 changed files
with
86 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* Increased maximum length for installer URLs specified in GitOps to 4000 characters |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
server/datastore/mysql/migrations/tables/20241219180042_LongInstallerURLs.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package tables | ||
|
||
import ( | ||
"database/sql" | ||
"fmt" | ||
) | ||
|
||
func init() { | ||
MigrationClient.AddMigration(Up_20241219180042, Down_20241219180042) | ||
} | ||
|
||
func Up_20241219180042(tx *sql.Tx) error { | ||
// The new 'url' column will only be set for software uploaded in batch via GitOps. | ||
if _, err := tx.Exec(` | ||
ALTER TABLE software_installers | ||
CHANGE COLUMN url url VARCHAR(4095) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ''; | ||
`); err != nil { | ||
return fmt.Errorf("failed to lengthen url in software_installers: %w", err) | ||
} | ||
return nil | ||
} | ||
|
||
func Down_20241219180042(tx *sql.Tx) error { | ||
return nil | ||
} |
51 changes: 51 additions & 0 deletions
51
server/datastore/mysql/migrations/tables/20241219180042_LongInstallerURLs_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package tables | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestUp_20241219180042(t *testing.T) { | ||
db := applyUpToPrev(t) | ||
|
||
script1 := execNoErrLastID(t, db, "INSERT INTO script_contents(contents, md5_checksum) VALUES ('echo hi', 'a')") | ||
script2 := execNoErrLastID(t, db, "INSERT INTO script_contents(contents, md5_checksum) VALUES ('echo bye', 'b')") | ||
|
||
software := execNoErrLastID(t, db, ` | ||
INSERT INTO software_installers ( | ||
filename, | ||
version, | ||
platform, | ||
install_script_content_id, | ||
post_install_script_content_id, | ||
uninstall_script_content_id, | ||
storage_id, | ||
package_ids, | ||
url | ||
) VALUES ( | ||
'fleet', | ||
'1.0.0', | ||
'windows', | ||
?, | ||
?, | ||
?, | ||
'a', | ||
'', | ||
? | ||
)`, script1, script2, script2, "https://google.com/") | ||
|
||
applyNext(t, db) | ||
|
||
var url string | ||
err := db.Get(&url, "SELECT url FROM software_installers WHERE id = ?", software) | ||
require.NoError(t, err) | ||
require.Equal(t, "https://google.com/", url) | ||
|
||
longUrl := "https://dl.google.com/tag/s/appguid%3D%7B8A69D345-D564-463C-AFF1-A69D9E530F96%7D%26iid%3D%7B53CCDE8D-FD40-46DE-67E7-61E96CFEFCAA%7D%26lang%3Den%26browser%3D4%26usagestats%3D0%26appname%3DGoogle%2520Chrome%26needsadmin%3Dtrue%26ap%3Dx64-stable-statsdef_0%26brand%3DGCEA/dl/chrome/install/googlechromestandaloneenterprise64.msi" | ||
execNoErr(t, db, `UPDATE software_installers SET url = ? WHERE id = ?`, longUrl, software) | ||
|
||
err = db.Get(&url, "SELECT url FROM software_installers WHERE id = ?", software) | ||
require.NoError(t, err) | ||
require.Equal(t, longUrl, url) | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters