-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add engine checks * Add engine checking * Add test to check engine checksum * Checksum read block * spaces cleanup * Tests update * engine source * Engine update * engine source * Tofu version check update * Cleanup * Engine update * Added test for signature checking * Extracted public key file * Test cleanup * File download update * Tests update
- Loading branch information
Showing
12 changed files
with
322 additions
and
49 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package engine | ||
|
||
const PublicKey = `-----BEGIN PGP PUBLIC KEY BLOCK----- | ||
mQGNBGaBbooBDADTCKKFW1uV5krG++w0u4QA7r2H6t39NfEKb8bbssM2oFIiTsEY | ||
6WQbddDAbzA9KFyIA47yga1nB3tOgih+4QwZF/Wctw63sfeKQ/kdT/p3lSwI1Rbq | ||
BuWJ0pSrZCsS8ldxNuel2Imnr3rZtB+jAWrfJio10T3paCy8HGE470ehXYpqlcUJ | ||
rOUxR4PTcLnWY0PrNfMgljXyFMLvqe1sG0LuPIH3ZbGZOzmdVyo/ngeJ9fluP8DC | ||
XZKEXqzGe58m6iJmDBUuRRV+LPVo8NrrVfF7waQrlGjaE4GZvvsmApxXv/iM9DIg | ||
NpZWE3vTH/pBSsc0HapVWD/DzYQpXhwcKWdF2wtpRrYOLFiXmdTHBga3xPDpXrID | ||
vPghYlW19j60A9o2MRzbjn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7IlTbnCCzhTn0H7TKAVNYwRpSYN2GOChMiowkJrqD22G9HVZth | ||
g/sBJlmAFvLy8Ed8ktbZ426Xm44WRS6MFglZJJKZSEXOdSla8F4GT0Zxd6hsc6A8 | ||
bLHQw34mFVmGZ6Q81+z2L3MV+zA3Dug3kEgRpH6g++KCX3+gpgsEugxli176rO1M | ||
CtZMnyR1fWBI9W8CuNm4MysImBHdOO73IUIsT2wiv4RTTGaLhU0YIfIEyojAFgEm | ||
S9BKCgF4BTP9FTOxxMZmINFTzDqi/b51qPBxBs6DXa/E7muOePzclQIBowARAQAB | ||
iQG2BBgBCgAgFiEEG3OoACM4wrso2zD0r1lo2nOb/FwFAmaBbooCGwwACgkQr1lo | ||
2nOb/FzonAwAw1jzHGUMAIPuLZAQNhrhj05ZbuC2A7TvWiQba9W1HPHFUZJgrxKW | ||
KNPaWb8oCQR8JDJlWqiZG6hWTAJ66suPrLF0KNnbiZ5Us4+o7Nv5q1i4lxpJRgoY | ||
FuCDZbQHXPn3jzSEDQPSA62+ZyRGxXfpqgVPpT8IPzAdCRAhMuUZb62h+WX2ey91 | ||
rnRFIXOlPTbrOMPLaMnGBjDnsWuCQmxBCXeevBh3u8q4Wa1xCZiqN8T7PSUusalu | ||
xita/w5ZA+Tzwxe8VqrgutCJdj5m5OxXX4v10xbbyPfhhnaahMduGL60MV/noxy6 | ||
9TFlXIhgDj8dxV8wt8Tv/GZSSUALaBuPs9U7Q+fGiPFpC48Q75y0uS0QWXm0taxs | ||
Rm6AMowi8dJEq1BIKvdEO2lDJ1uSw5Xcamj6Nu0JrM8tc1uCFNYOAEHw2bDHIcHK | ||
+uFqASiTa9QRj1SpSRkbPJB3yuPgUr1DgEoolSlMOnUiI46K3I9APD54nuShVbVq | ||
iE6bHk4c9kBU | ||
=TmYc | ||
-----END PGP PUBLIC KEY BLOCK-----` |
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,54 @@ | ||
package engine | ||
|
||
import ( | ||
"bytes" | ||
"crypto/sha256" | ||
"encoding/hex" | ||
"os" | ||
"path/filepath" | ||
"strings" | ||
|
||
"github.com/ProtonMail/go-crypto/openpgp" | ||
"github.com/gruntwork-io/go-commons/errors" | ||
"github.com/gruntwork-io/terragrunt/util" | ||
) | ||
|
||
// verifyFile verifies the checksums file and the signature file of the passed file | ||
func verifyFile(checkedFile, checksumsFile, signatureFile string) error { | ||
checksums, err := os.ReadFile(checksumsFile) | ||
if err != nil { | ||
return errors.WithStackTrace(err) | ||
} | ||
checksumsSignature, err := os.ReadFile(signatureFile) | ||
if err != nil { | ||
return errors.WithStackTrace(err) | ||
} | ||
// validate first checksum file signature | ||
keyring, err := openpgp.ReadArmoredKeyRing(strings.NewReader(PublicKey)) | ||
if err != nil { | ||
return errors.WithStackTrace(err) | ||
} | ||
_, err = openpgp.CheckDetachedSignature(keyring, bytes.NewReader(checksums), bytes.NewReader(checksumsSignature), nil) | ||
if err != nil { | ||
return errors.WithStackTrace(err) | ||
} | ||
// verify checksums | ||
// calculate checksum of package file | ||
packageChecksum, err := util.FileSHA256(checkedFile) | ||
if err != nil { | ||
return errors.WithStackTrace(err) | ||
} | ||
// match expected checksum | ||
expectedChecksum := util.MatchSha256Checksum(checksums, []byte(filepath.Base(checkedFile))) | ||
if expectedChecksum == nil { | ||
return errors.Errorf("checksum list has no entry for %s", checkedFile) | ||
} | ||
var expectedSHA256Sum [sha256.Size]byte | ||
if _, err := hex.Decode(expectedSHA256Sum[:], expectedChecksum); err != nil { | ||
return errors.WithStackTrace(err) | ||
} | ||
if !bytes.Equal(expectedSHA256Sum[:], packageChecksum) { | ||
return errors.Errorf("checksum list has unexpected SHA-256 hash %x (expected %x)", packageChecksum, expectedSHA256Sum) | ||
} | ||
return nil | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
engine { | ||
source = "github.com/gruntwork-io/terragrunt-engine-opentofu" | ||
version = "v0.0.2" | ||
version = "v0.0.4" | ||
type = "rpc" | ||
} |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
engine { | ||
source = "__hardcoded_url__" | ||
version = "v0.0.2" | ||
version = "v0.0.4" | ||
} | ||
|
||
inputs = { | ||
|
Oops, something went wrong.