Skip to content

Commit dcc4cab

Browse files
author
Akshay Rane
committed
Resolved a test case that referred to intrinsic functions
1 parent d87282b commit dcc4cab

File tree

3 files changed

+13
-19
lines changed

3 files changed

+13
-19
lines changed

Cargo.lock

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

guard/resources/test-command/output-dir/test_data_dir_verbose_prev_engine.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ Rule(S3_BUCKET_LOGGING_ENABLED, PASS)
3030
Condition(S3_BUCKET_LOGGING_ENABLED, PASS)
3131
| Message: DEFAULT MESSAGE(PASS)
3232
Clause( %s3_buckets_bucket_logging_enabled not EMPTY , PASS)
33-
| From: Map((Path("/Resources/ExampleS3", Location { line: 0, col: 0 }), MapValue { keys: [String((Path("/Resources/ExampleS3/Type", Location { line: 0, col: 0 }), "Type")), String((Path("/Resources/ExampleS3/Properties", Location { line: 0, col: 0 }), "Properties"))], values: {"Type": String((Path("/Resources/ExampleS3/Type", Location { line: 0, col: 0 }), "AWS::S3::Bucket")), "Properties": Map((Path("/Resources/ExampleS3/Properties", Location { line: 0, col: 0 }), MapValue { keys: [String((Path("/Resources/ExampleS3/Properties/BucketName", Location { line: 0, col: 0 }), "BucketName")), String((Path("/Resources/ExampleS3/Properties/VersioningConfiguration", Location { line: 0, col: 0 }), "VersioningConfiguration")), String((Path("/Resources/ExampleS3/Properties/LoggingConfiguration", Location { line: 0, col: 0 }), "LoggingConfiguration"))], values: {"BucketName": String((Path("/Resources/ExampleS3/Properties/BucketName", Location { line: 0, col: 0 }), "my-bucket")), "VersioningConfiguration": Map((Path("/Resources/ExampleS3/Properties/VersioningConfiguration", Location { line: 0, col: 0 }), MapValue { keys: [String((Path("/Resources/ExampleS3/Properties/VersioningConfiguration/Status", Location { line: 0, col: 0 }), "Status"))], values: {"Status": String((Path("/Resources/ExampleS3/Properties/VersioningConfiguration/Status", Location { line: 0, col: 0 }), "Enabled"))} })), "LoggingConfiguration": Map((Path("/Resources/ExampleS3/Properties/LoggingConfiguration", Location { line: 0, col: 0 }), MapValue { keys: [String((Path("/Resources/ExampleS3/Properties/LoggingConfiguration/DestinationBucketName", Location { line: 0, col: 0 }), "DestinationBucketName")), String((Path("/Resources/ExampleS3/Properties/LoggingConfiguration/LogFilePrefix", Location { line: 0, col: 0 }), "LogFilePrefix"))], values: {"DestinationBucketName": Map((Path("/Resources/ExampleS3/Properties/LoggingConfiguration/DestinationBucketName", Location { line: 0, col: 0 }), MapValue { keys: [String((Path("/Resources/ExampleS3/Properties/LoggingConfiguration/DestinationBucketName/Ref", Location { line: 0, col: 0 }), "Ref"))], values: {"Ref": String((Path("/Resources/ExampleS3/Properties/LoggingConfiguration/DestinationBucketName/Ref", Location { line: 0, col: 0 }), "LoggingBucket"))} })), "LogFilePrefix": String((Path("/Resources/ExampleS3/Properties/LoggingConfiguration/LogFilePrefix", Location { line: 0, col: 0 }), "testing-logs"))} }))} }))} }))
33+
| From: Map((Path("/Resources/ExampleS3", Location { line: 0, col: 0 }), MapValue { keys: [String((Path("/Resources/ExampleS3/Type", Location { line: 0, col: 0 }), "Type")), String((Path("/Resources/ExampleS3/Properties", Location { line: 0, col: 0 }), "Properties"))], values: {"Type": String((Path("/Resources/ExampleS3/Type", Location { line: 0, col: 0 }), "AWS::S3::Bucket")), "Properties": Map((Path("/Resources/ExampleS3/Properties", Location { line: 0, col: 0 }), MapValue { keys: [String((Path("/Resources/ExampleS3/Properties/BucketName", Location { line: 0, col: 0 }), "BucketName")), String((Path("/Resources/ExampleS3/Properties/VersioningConfiguration", Location { line: 0, col: 0 }), "VersioningConfiguration")), String((Path("/Resources/ExampleS3/Properties/LoggingConfiguration", Location { line: 0, col: 0 }), "LoggingConfiguration"))], values: {"BucketName": String((Path("/Resources/ExampleS3/Properties/BucketName", Location { line: 0, col: 0 }), "my-bucket")), "VersioningConfiguration": Map((Path("/Resources/ExampleS3/Properties/VersioningConfiguration", Location { line: 0, col: 0 }), MapValue { keys: [String((Path("/Resources/ExampleS3/Properties/VersioningConfiguration/Status", Location { line: 0, col: 0 }), "Status"))], values: {"Status": String((Path("/Resources/ExampleS3/Properties/VersioningConfiguration/Status", Location { line: 0, col: 0 }), "Enabled"))} })), "LoggingConfiguration": Map((Path("/Resources/ExampleS3/Properties/LoggingConfiguration", Location { line: 0, col: 0 }), MapValue { keys: [String((Path("/Resources/ExampleS3/Properties/LoggingConfiguration/DestinationBucketName", Location { line: 0, col: 0 }), "DestinationBucketName")), String((Path("/Resources/ExampleS3/Properties/LoggingConfiguration/LogFilePrefix", Location { line: 0, col: 0 }), "LogFilePrefix"))], values: {"DestinationBucketName": String((Path("/Resources/ExampleS3/Properties/LoggingConfiguration/DestinationBucketName", Location { line: 0, col: 0 }), "LoggingBucket")), "LogFilePrefix": String((Path("/Resources/ExampleS3/Properties/LoggingConfiguration/LogFilePrefix", Location { line: 0, col: 0 }), "testing-logs"))} }))} }))} }))
3434
| Message: DEFAULT MESSAGE(PASS)
3535
Clause( %s3_buckets_bucket_logging_enabled[*].Properties.LoggingConfiguration EXISTS , PASS)
36-
| From: Map((Path("/Resources/ExampleS3/Properties/LoggingConfiguration", Location { line: 0, col: 0 }), MapValue { keys: [String((Path("/Resources/ExampleS3/Properties/LoggingConfiguration/DestinationBucketName", Location { line: 0, col: 0 }), "DestinationBucketName")), String((Path("/Resources/ExampleS3/Properties/LoggingConfiguration/LogFilePrefix", Location { line: 0, col: 0 }), "LogFilePrefix"))], values: {"DestinationBucketName": Map((Path("/Resources/ExampleS3/Properties/LoggingConfiguration/DestinationBucketName", Location { line: 0, col: 0 }), MapValue { keys: [String((Path("/Resources/ExampleS3/Properties/LoggingConfiguration/DestinationBucketName/Ref", Location { line: 0, col: 0 }), "Ref"))], values: {"Ref": String((Path("/Resources/ExampleS3/Properties/LoggingConfiguration/DestinationBucketName/Ref", Location { line: 0, col: 0 }), "LoggingBucket"))} })), "LogFilePrefix": String((Path("/Resources/ExampleS3/Properties/LoggingConfiguration/LogFilePrefix", Location { line: 0, col: 0 }), "testing-logs"))} }))
36+
| From: Map((Path("/Resources/ExampleS3/Properties/LoggingConfiguration", Location { line: 0, col: 0 }), MapValue { keys: [String((Path("/Resources/ExampleS3/Properties/LoggingConfiguration/DestinationBucketName", Location { line: 0, col: 0 }), "DestinationBucketName")), String((Path("/Resources/ExampleS3/Properties/LoggingConfiguration/LogFilePrefix", Location { line: 0, col: 0 }), "LogFilePrefix"))], values: {"DestinationBucketName": String((Path("/Resources/ExampleS3/Properties/LoggingConfiguration/DestinationBucketName", Location { line: 0, col: 0 }), "LoggingBucket")), "LogFilePrefix": String((Path("/Resources/ExampleS3/Properties/LoggingConfiguration/LogFilePrefix", Location { line: 0, col: 0 }), "testing-logs"))} }))
3737
| Message: DEFAULT MESSAGE(PASS)
3838
PASS Rules:
3939
S3_BUCKET_LOGGING_ENABLED: Expected = PASS, Evaluated = PASS

guard/src/rules/values.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ use std::{
88
use indexmap::map::IndexMap;
99
use nom::lib::std::fmt::Formatter;
1010

11-
use crate::rules::{
12-
errors::Error, libyaml::loader::Loader, parser::Span, path_value::Location, short_form_to_long,
13-
SEQUENCE_VALUE_FUNC_REF, SINGLE_VALUE_FUNC_REF,
14-
};
11+
use crate::rules::{errors::Error, libyaml::loader::Loader, parser::Span, path_value::Location};
1512

1613
use serde::{Deserialize, Serialize};
1714

@@ -306,18 +303,7 @@ impl<'a> TryFrom<&'a serde_yaml::Value> for Value {
306303
Ok(res)
307304
},
308305
)?)),
309-
serde_yaml::Value::Tagged(tag) => {
310-
let prefix = tag.tag.to_string();
311-
let value = tag.value.clone();
312-
313-
match prefix.matches('!').count() {
314-
1 => {
315-
let stripped_prefix = prefix.strip_prefix('!').unwrap();
316-
Ok(handle_tagged_value(value, stripped_prefix)?)
317-
}
318-
_ => Ok(Value::try_from(value)?),
319-
}
320-
}
306+
serde_yaml::Value::Tagged(tag) => Ok(Value::try_from(tag.value.clone())?),
321307
serde_yaml::Value::Null => Ok(Value::Null),
322308
}
323309
}

0 commit comments

Comments
 (0)