Skip to content

Commit

Permalink
Only allow the strings 'true' and 'false' to pass the type checker
Browse files Browse the repository at this point in the history
  • Loading branch information
guineveresaenger committed Oct 28, 2024
1 parent 078e63e commit 2ee1a9a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/tfbridge/typechecker/typechecker.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,15 @@ func (v *TypeChecker) validatePropertyValue(

switch typeSpec.Type {
case "boolean":
// The bridge permits the strings "true" and "false" to read as boolean, so allow strings.
if !propertyValue.IsBool() && !propertyValue.IsString() {
// Check for strings that are values "true" or "false".
// These are handled as booleans in the bridge, so they should be skipped by the type checker.
var boolString bool
if propertyValue.IsString() {
if propertyValue.StringValue() == "true" || propertyValue.StringValue() == "false" {
boolString = true
}
}
if !propertyValue.IsBool() && !boolString {
return []Failure{newTypeFailure(propertyPath, typeSpec.Type, propertyValue)}
}
return nil
Expand Down

0 comments on commit 2ee1a9a

Please sign in to comment.