mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-22 14:10:56 -05:00
Improve template detection
This commit is contained in:
parent
f1d1b1cbe2
commit
eb8cf40bf5
4 changed files with 49 additions and 3 deletions
16
.automation/test/cfn/cfn_bad_3.json
Normal file
16
.automation/test/cfn/cfn_bad_3.json
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"Resources" : {
|
||||||
|
"myDNSRecord" : {
|
||||||
|
"Type" : "AWS::Route53::RecordSet",
|
||||||
|
"Properties" : {
|
||||||
|
"HostedZoneId" : "Z8VLZEXAMPLE",
|
||||||
|
"Name" : "test.example.com",
|
||||||
|
"ResourceRecords" : [
|
||||||
|
"192.0.2.99"
|
||||||
|
],
|
||||||
|
"Ttl" : 300,
|
||||||
|
"Type" : "A"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
16
.automation/test/cfn/cfn_good_3.json
Normal file
16
.automation/test/cfn/cfn_good_3.json
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"Resources" : {
|
||||||
|
"myDNSRecord" : {
|
||||||
|
"Type" : "AWS::Route53::RecordSet",
|
||||||
|
"Properties" : {
|
||||||
|
"HostedZoneId" : "Z8VLZEXAMPLE",
|
||||||
|
"Name" : "test.example.com",
|
||||||
|
"ResourceRecords" : [
|
||||||
|
"192.0.2.99"
|
||||||
|
],
|
||||||
|
"TTL" : 300,
|
||||||
|
"Type" : "A"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -53,7 +53,7 @@ RUN mkdir -p /opt/microsoft/powershell/7 \
|
||||||
# Run Pip3 Installs #
|
# Run Pip3 Installs #
|
||||||
#####################
|
#####################
|
||||||
RUN pip3 --no-cache-dir install --upgrade --no-cache-dir \
|
RUN pip3 --no-cache-dir install --upgrade --no-cache-dir \
|
||||||
yamllint pylint yq cfn-lint
|
yamllint pylint yq cfn-lint shyaml
|
||||||
|
|
||||||
####################
|
####################
|
||||||
# Run NPM Installs #
|
# Run NPM Installs #
|
||||||
|
|
|
@ -616,11 +616,25 @@ DetectOpenAPIFile()
|
||||||
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-formats.html
|
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-formats.html
|
||||||
DetectCloudFormationFile()
|
DetectCloudFormationFile()
|
||||||
{
|
{
|
||||||
|
# AWSTemplateFormatVersion is optional
|
||||||
|
# grep -E '("|)AWSTemplateFormatVersion("|):'
|
||||||
if grep 'AWSTemplateFormatVersion' "${1}" > /dev/null; then
|
if grep 'AWSTemplateFormatVersion' "${1}" > /dev/null; then
|
||||||
return 0
|
return 0
|
||||||
else
|
|
||||||
return 1
|
|
||||||
fi
|
fi
|
||||||
|
if cat "${1}" | shyaml --quiet get-type AWSTemplateFormatVersion > /dev/null; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if cat "${1}" | jq -e 'has("Resources")' > /dev/null 2>&1; then
|
||||||
|
if cat "${1}" | jq ".Resources[].Type" 2>/dev/null | grep -q -E "(AWS|Alexa|Custom)"; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if cat "${1}" | shyaml values-0 Resources | grep -q -E "Type: (AWS|Alexa|Custom)"; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
Loading…
Reference in a new issue