Compare commits

..

5 commits

Author SHA1 Message Date
1ffa5a23bd
Merge pull request #59 from passbolt/v5-schema-fixes
Some checks failed
Go / test (push) Has been cancelled
V5 schema fixes
2025-08-11 15:53:14 +02:00
1111e12f1e Fix Metadata Parsing for v5-totp-standalone 2025-08-11 15:40:10 +02:00
09ecd1f23a Fix null's in schema 2025-08-11 15:39:48 +02:00
9c9e2334dc
Merge pull request #58 from passbolt/fix-password-string-validation
Fix resource type password-string validation
2025-08-11 15:37:47 +02:00
2cb39e9481 Fix resource type password-string validation 2025-08-11 15:36:01 +02:00
3 changed files with 50 additions and 47 deletions

View file

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

View file

@ -173,7 +173,21 @@ func GetResourceFromData(c *api.Client, resource api.Resource, secret api.Secret
pw = rawSecretData
case "v5-totp-standalone":
// nothing fits into the interface in this case
rawMetadata, err := GetResourceMetadata(ctx, c, &resource, &rType)
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:
return "", "", "", "", "", "", fmt.Errorf("Unknown ResourceType: %v", rType.Slug)
}

View file

@ -11,6 +11,15 @@ import (
)
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
definition := rType.Definition