Compare commits

..

No commits in common. "1ffa5a23bd2933680f6032b26eed742ce5bc57eb" and "8b00fcd4971ec6b7c454ebc064d6ad1b0a52eb92" have entirely different histories.

3 changed files with 47 additions and 50 deletions

View file

@ -15,19 +15,22 @@ var ResourceSchemas = map[string]json.RawMessage{
"maxLength": 255 "maxLength": 255
}, },
"username": { "username": {
"type": ["string", "null"], "type": "string",
"maxLength": 255 "maxLength": 255,
"nullable": true
}, },
"uris": { "uris": {
"type": "array", "type": "array",
"items": { "items": {
"type": "string", "type": "string",
"maxLength": 1024 "maxLength": 1024,
"nullable": true
} }
}, },
"description": { "description": {
"type": ["string", "null"], "type": "string",
"maxLength": 10000 "maxLength": 10000,
"nullable": true
} }
} }
}, },
@ -40,12 +43,14 @@ var ResourceSchemas = map[string]json.RawMessage{
"enum": ["PASSBOLT_SECRET_DATA"] "enum": ["PASSBOLT_SECRET_DATA"]
}, },
"password": { "password": {
"type": ["string", "null"], "type": "string",
"maxLength": 4096 "maxLength": 4096,
"nullable": true
}, },
"description": { "description": {
"type": ["string", "null"], "type": "string",
"maxLength": 10000 "maxLength": 10000,
"nullable": true
} }
} }
} }
@ -61,19 +66,22 @@ var ResourceSchemas = map[string]json.RawMessage{
"maxLength": 255 "maxLength": 255
}, },
"username": { "username": {
"type": ["string", "null"], "type": "string",
"maxLength": 255 "maxLength": 255,
"nullable": true
}, },
"uris": { "uris": {
"type": "array", "type": "array",
"items": { "items": {
"type": "string", "type": "string",
"maxLength": 1024 "maxLength": 1024,
"nullable": true
} }
}, },
"description": { "description": {
"type": ["string", "null"], "type": "string",
"maxLength": 10000 "maxLength": 10000,
"nullable": true
} }
} }
}, },
@ -93,19 +101,22 @@ var ResourceSchemas = map[string]json.RawMessage{
"maxLength": 255 "maxLength": 255
}, },
"username": { "username": {
"type": ["string", "null"], "type": "string",
"maxLength": 255 "maxLength": 255,
"nullable": true
}, },
"uris": { "uris": {
"type": "array", "type": "array",
"items": { "items": {
"type": "string", "type": "string",
"maxLength": 1024 "maxLength": 1024,
"nullable": true
} }
}, },
"description": { "description": {
"type": ["string", "null"], "type": "string",
"maxLength": 10000 "maxLength": 10000,
"nullable": true
} }
} }
}, },
@ -118,12 +129,14 @@ var ResourceSchemas = map[string]json.RawMessage{
"enum": ["PASSBOLT_SECRET_DATA"] "enum": ["PASSBOLT_SECRET_DATA"]
}, },
"password": { "password": {
"type": ["string", "null"], "type": "string",
"maxLength": 4096 "maxLength": 4096,
"nullable": true
}, },
"description": { "description": {
"type": ["string", "null"], "type": "string",
"maxLength": 10000 "maxLength": 10000,
"nullable": true
}, },
"totp": { "totp": {
"type": "object", "type": "object",
@ -161,16 +174,23 @@ var ResourceSchemas = map[string]json.RawMessage{
"type": "string", "type": "string",
"maxLength": 255 "maxLength": 255
}, },
"username": {
"type": "string",
"maxLength": 255,
"nullable": true
},
"uris": { "uris": {
"type": "array", "type": "array",
"items": { "items": {
"type": "string", "type": "string",
"maxLength": 1024 "maxLength": 1024,
"nullable": true
} }
}, },
"description": { "description": {
"type": ["string", "null"], "type": "string",
"maxLength": 10000 "maxLength": 10000,
"nullable": true
} }
} }
}, },

View file

@ -173,21 +173,7 @@ func GetResourceFromData(c *api.Client, resource api.Resource, secret api.Secret
pw = rawSecretData pw = rawSecretData
case "v5-totp-standalone": case "v5-totp-standalone":
rawMetadata, err := GetResourceMetadata(ctx, c, &resource, &rType) // nothing fits into the interface in this case
if err != nil {
return "", "", "", "", "", "", fmt.Errorf("Getting Metadata: %w", err)
}
var metadata api.ResourceMetadataTypeV5TOTPStandalone
err = json.Unmarshal([]byte(rawMetadata), &metadata)
if err != nil {
return "", "", "", "", "", "", fmt.Errorf("Parsing Decrypted Metadata: %w", err)
}
name = metadata.Name
if len(metadata.URIs) != 0 {
uri = metadata.URIs[0]
}
default: default:
return "", "", "", "", "", "", fmt.Errorf("Unknown ResourceType: %v", rType.Slug) return "", "", "", "", "", "", fmt.Errorf("Unknown ResourceType: %v", rType.Slug)
} }

View file

@ -11,15 +11,6 @@ import (
) )
func validateSecretData(rType *api.ResourceType, secretData string) error { func validateSecretData(rType *api.ResourceType, secretData string) error {
// TODO Remove when v4 Resources are unsupported
// with the Resource Type password-string the Secret is not json and can't be properly validated, so skip the check here
if rType.Slug == "password-string" {
if len(secretData) > 4096 {
return fmt.Errorf("password is longer than 4096")
}
return nil
}
var schemaDefinition api.ResourceTypeSchema var schemaDefinition api.ResourceTypeSchema
definition := rType.Definition definition := rType.Definition