diff --git a/api/schema.go b/api/schema.go index 0f351ac..b9fe6d4 100644 --- a/api/schema.go +++ b/api/schema.go @@ -15,19 +15,22 @@ var ResourceSchemas = map[string]json.RawMessage{ "maxLength": 255 }, "username": { - "type": ["string", "null"], - "maxLength": 255 + "type": "string", + "maxLength": 255, + "nullable": true }, "uris": { "type": "array", "items": { "type": "string", - "maxLength": 1024 + "maxLength": 1024, + "nullable": true } }, "description": { - "type": ["string", "null"], - "maxLength": 10000 + "type": "string", + "maxLength": 10000, + "nullable": true } } }, @@ -40,12 +43,14 @@ var ResourceSchemas = map[string]json.RawMessage{ "enum": ["PASSBOLT_SECRET_DATA"] }, "password": { - "type": ["string", "null"], - "maxLength": 4096 + "type": "string", + "maxLength": 4096, + "nullable": true }, "description": { - "type": ["string", "null"], - "maxLength": 10000 + "type": "string", + "maxLength": 10000, + "nullable": true } } } @@ -61,19 +66,22 @@ var ResourceSchemas = map[string]json.RawMessage{ "maxLength": 255 }, "username": { - "type": ["string", "null"], - "maxLength": 255 + "type": "string", + "maxLength": 255, + "nullable": true }, "uris": { "type": "array", "items": { "type": "string", - "maxLength": 1024 + "maxLength": 1024, + "nullable": true } }, "description": { - "type": ["string", "null"], - "maxLength": 10000 + "type": "string", + "maxLength": 10000, + "nullable": true } } }, @@ -93,19 +101,22 @@ var ResourceSchemas = map[string]json.RawMessage{ "maxLength": 255 }, "username": { - "type": ["string", "null"], - "maxLength": 255 + "type": "string", + "maxLength": 255, + "nullable": true }, "uris": { "type": "array", "items": { "type": "string", - "maxLength": 1024 + "maxLength": 1024, + "nullable": true } }, "description": { - "type": ["string", "null"], - "maxLength": 10000 + "type": "string", + "maxLength": 10000, + "nullable": true } } }, @@ -118,12 +129,14 @@ var ResourceSchemas = map[string]json.RawMessage{ "enum": ["PASSBOLT_SECRET_DATA"] }, "password": { - "type": ["string", "null"], - "maxLength": 4096 + "type": "string", + "maxLength": 4096, + "nullable": true }, "description": { - "type": ["string", "null"], - "maxLength": 10000 + "type": "string", + "maxLength": 10000, + "nullable": true }, "totp": { "type": "object", @@ -161,16 +174,23 @@ 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 + "maxLength": 1024, + "nullable": true } }, "description": { - "type": ["string", "null"], - "maxLength": 10000 + "type": "string", + "maxLength": 10000, + "nullable": true } } }, diff --git a/helper/resource_get.go b/helper/resource_get.go index 64fcc1f..7967bae 100644 --- a/helper/resource_get.go +++ b/helper/resource_get.go @@ -173,21 +173,7 @@ func GetResourceFromData(c *api.Client, resource api.Resource, secret api.Secret pw = rawSecretData case "v5-totp-standalone": - 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] - } + // nothing fits into the interface in this case default: return "", "", "", "", "", "", fmt.Errorf("Unknown ResourceType: %v", rType.Slug) } diff --git a/helper/secret.go b/helper/secret.go index 502bfe7..586ac26 100644 --- a/helper/secret.go +++ b/helper/secret.go @@ -11,15 +11,6 @@ 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