зеркало из https://github.com/getsops/sops.git
Use time.RFC3339 instead of custom format
This commit is contained in:
Родитель
e885735260
Коммит
762c5cd559
|
@ -137,7 +137,7 @@ func (k KMSMasterKey) ToMap() map[string]string {
|
|||
if k.Role != "" {
|
||||
out["role"] = k.Role
|
||||
}
|
||||
out["created_at"] = k.CreationDate.Format("2006-01-02T15:04:05Z")
|
||||
out["created_at"] = k.CreationDate.Format(time.RFC3339)
|
||||
out["enc"] = k.EncryptedKey
|
||||
return out
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -194,7 +195,7 @@ func decrypt(c *cli.Context, file string, fileBytes []byte, output io.Writer) er
|
|||
if err != nil {
|
||||
return cli.NewExitError(fmt.Sprintf("Error decrypting tree: %s", err), 8)
|
||||
}
|
||||
originalMac, err := aes.Decrypt([]byte(metadata.MessageAuthenticationCode), key, []byte(metadata.LastModified.Format(sops.DateFormat)))
|
||||
originalMac, err := aes.Decrypt([]byte(metadata.MessageAuthenticationCode), key, []byte(metadata.LastModified.Format(time.RFC3339)))
|
||||
if originalMac != mac && !c.Bool("ignore-mac") {
|
||||
return cli.NewExitError("MAC mismatch.", 9)
|
||||
}
|
||||
|
@ -273,7 +274,7 @@ func rotate(c *cli.Context, file string, fileBytes []byte, output io.Writer) err
|
|||
if err != nil {
|
||||
return cli.NewExitError(fmt.Sprintf("Error decrypting tree: %s", err), 8)
|
||||
}
|
||||
originalMac, err := aes.Decrypt([]byte(metadata.MessageAuthenticationCode), key, []byte(metadata.LastModified.Format(sops.DateFormat)))
|
||||
originalMac, err := aes.Decrypt([]byte(metadata.MessageAuthenticationCode), key, []byte(metadata.LastModified.Format(time.RFC3339)))
|
||||
if originalMac != mac && !c.Bool("ignore-mac") {
|
||||
return cli.NewExitError("MAC mismatch.", 9)
|
||||
}
|
||||
|
|
|
@ -16,8 +16,6 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
const DateFormat = "2006-01-02T15:04:05Z"
|
||||
|
||||
type GPGMasterKey struct {
|
||||
Fingerprint string
|
||||
EncryptedKey string
|
||||
|
@ -196,7 +194,7 @@ func (key *GPGMasterKey) passphrasePrompt(keys []openpgp.Key, symmetric bool) ([
|
|||
func (key GPGMasterKey) ToMap() map[string]string {
|
||||
out := make(map[string]string)
|
||||
out["fp"] = key.Fingerprint
|
||||
out["created_at"] = key.CreationDate.Format(DateFormat)
|
||||
out["created_at"] = key.CreationDate.Format(time.RFC3339)
|
||||
out["enc"] = key.EncryptedKey
|
||||
return out
|
||||
}
|
||||
|
|
2
sops.go
2
sops.go
|
@ -11,8 +11,6 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
const DateFormat = "2006-01-02T15:04:05Z"
|
||||
|
||||
const DefaultUnencryptedSuffix = "_unencrypted"
|
||||
|
||||
type Error string
|
||||
|
|
|
@ -115,7 +115,7 @@ func (store *Store) LoadMetadata(in string) (sops.Metadata, error) {
|
|||
}
|
||||
data = data["sops"].(map[interface{}]interface{})
|
||||
metadata.MessageAuthenticationCode = data["mac"].(string)
|
||||
lastModified, err := time.Parse(sops.DateFormat, data["lastmodified"].(string))
|
||||
lastModified, err := time.Parse(time.RFC3339, data["lastmodified"].(string))
|
||||
if err != nil {
|
||||
return metadata, fmt.Errorf("Could not parse last modified date: %s", err)
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ func (store *Store) kmsEntries(in []interface{}) (sops.KeySource, error) {
|
|||
if ok {
|
||||
key.Role = role
|
||||
}
|
||||
creationDate, err := time.Parse(sops.DateFormat, entry["created_at"].(string))
|
||||
creationDate, err := time.Parse(time.RFC3339, entry["created_at"].(string))
|
||||
if err != nil {
|
||||
return keysource, fmt.Errorf("Could not parse creation date: %s", err)
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ func (store *Store) pgpEntries(in []interface{}) (sops.KeySource, error) {
|
|||
key := &pgp.GPGMasterKey{}
|
||||
key.Fingerprint = entry["fp"].(string)
|
||||
key.EncryptedKey = entry["enc"].(string)
|
||||
creationDate, err := time.Parse(sops.DateFormat, entry["created_at"].(string))
|
||||
creationDate, err := time.Parse(time.RFC3339, entry["created_at"].(string))
|
||||
if err != nil {
|
||||
return keysource, fmt.Errorf("Could not parse creation date: %s", err)
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче