Skip to content

Commit

Permalink
fix e2e-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
patilpankaj212 committed Apr 18, 2021
1 parent 1825779 commit d3ff6be
Show file tree
Hide file tree
Showing 25 changed files with 206 additions and 52 deletions.
2 changes: 1 addition & 1 deletion pkg/results/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type Violation struct {
ResourceType string `json:"resource_type" yaml:"resource_type" xml:"resource_type,attr"`
ResourceData interface{} `json:"-" yaml:"-" xml:"-"`
File string `json:"file" yaml:"file" xml:"file,attr"`
RootPath string `json:"root_path,omitempty" yaml:"root_path,omitempty" xml:"root_path,omitempty"`
RootPath string `json:"root_path,omitempty" yaml:"root_path,omitempty" xml:"root_path,attr,omitempty"`
LineNumber int `json:"line" yaml:"line" xml:"line,attr"`
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"resource_name": "PtShGgAdi6",
"resource_type": "aws_db_instance",
"file": "main.tf",
"root_path": "./",
"line": 85
},
{
Expand All @@ -21,6 +22,7 @@
"resource_name": "PtShGgAdi3",
"resource_type": "aws_db_instance",
"file": "main.tf",
"root_path": "./",
"line": 39
},
{
Expand All @@ -32,6 +34,7 @@
"resource_name": "PtShGgAdi1",
"resource_type": "aws_db_instance",
"file": "main.tf",
"root_path": "./",
"line": 10
},
{
Expand All @@ -43,6 +46,7 @@
"resource_name": "PtShGgAdi2",
"resource_type": "aws_db_instance",
"file": "main.tf",
"root_path": "./",
"line": 25
},
{
Expand All @@ -54,6 +58,7 @@
"resource_name": "PtShGgAdi5",
"resource_type": "aws_db_instance",
"file": "main.tf",
"root_path": "./",
"line": 71
},
{
Expand All @@ -65,6 +70,7 @@
"resource_name": "PtShGgAdi3",
"resource_type": "aws_db_instance",
"file": "main.tf",
"root_path": "./",
"line": 39
},
{
Expand All @@ -76,6 +82,7 @@
"resource_name": "PtShGgAdi6",
"resource_type": "aws_db_instance",
"file": "main.tf",
"root_path": "./",
"line": 85
},
{
Expand All @@ -87,6 +94,7 @@
"resource_name": "PtShGgAdi2",
"resource_type": "aws_db_instance",
"file": "main.tf",
"root_path": "./",
"line": 25
},
{
Expand All @@ -98,6 +106,7 @@
"resource_name": "PtShGgAdi3",
"resource_type": "aws_db_instance",
"file": "main.tf",
"root_path": "./",
"line": 39
},
{
Expand All @@ -109,6 +118,7 @@
"resource_name": "PtShGgAdi3",
"resource_type": "aws_db_instance",
"file": "main.tf",
"root_path": "./",
"line": 39
},
{
Expand All @@ -120,6 +130,7 @@
"resource_name": "PtShGgAdi3",
"resource_type": "aws_db_instance",
"file": "main.tf",
"root_path": "./",
"line": 39
}
],
Expand All @@ -134,6 +145,7 @@
"resource_name": "PtShGgAdi4",
"resource_type": "aws_db_instance",
"file": "main.tf",
"root_path": "./",
"line": 55
},
{
Expand All @@ -146,6 +158,7 @@
"resource_name": "PtShGgAdi4",
"resource_type": "aws_db_instance",
"file": "main.tf",
"root_path": "./",
"line": 55
},
{
Expand All @@ -158,6 +171,7 @@
"resource_name": "PtShGgAdi5",
"resource_type": "aws_db_instance",
"file": "main.tf",
"root_path": "./",
"line": 71
}
],
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/scan/golden/rules_filtering/scan_and_skip_rules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"resource_name": "PtShGgAdi3",
"resource_type": "aws_db_instance",
"file": "main.tf",
"root_path": "./",
"line": 39
},
{
Expand All @@ -21,6 +22,7 @@
"resource_name": "PtShGgAdi3",
"resource_type": "aws_db_instance",
"file": "main.tf",
"root_path": "./",
"line": 39
}
],
Expand Down
8 changes: 8 additions & 0 deletions test/e2e/scan/golden/rules_filtering/scan_multiple_rules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"resource_name": "PtShGgAdi3",
"resource_type": "aws_db_instance",
"file": "main.tf",
"root_path": "./",
"line": 39
},
{
Expand All @@ -21,6 +22,7 @@
"resource_name": "PtShGgAdi3",
"resource_type": "aws_db_instance",
"file": "main.tf",
"root_path": "./",
"line": 39
},
{
Expand All @@ -32,6 +34,7 @@
"resource_name": "PtShGgAdi3",
"resource_type": "aws_db_instance",
"file": "main.tf",
"root_path": "./",
"line": 39
},
{
Expand All @@ -43,6 +46,7 @@
"resource_name": "PtShGgAdi2",
"resource_type": "aws_db_instance",
"file": "main.tf",
"root_path": "./",
"line": 25
},
{
Expand All @@ -54,6 +58,7 @@
"resource_name": "PtShGgAdi4",
"resource_type": "aws_db_instance",
"file": "main.tf",
"root_path": "./",
"line": 55
},
{
Expand All @@ -65,6 +70,7 @@
"resource_name": "PtShGgAdi5",
"resource_type": "aws_db_instance",
"file": "main.tf",
"root_path": "./",
"line": 69
},
{
Expand All @@ -76,6 +82,7 @@
"resource_name": "PtShGgAdi6",
"resource_type": "aws_db_instance",
"file": "main.tf",
"root_path": "./",
"line": 82
},
{
Expand All @@ -87,6 +94,7 @@
"resource_name": "PtShGgAdi3",
"resource_type": "aws_db_instance",
"file": "main.tf",
"root_path": "./",
"line": 39
}
],
Expand Down
1 change: 1 addition & 0 deletions test/e2e/scan/golden/rules_filtering/scan_single_rule.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"resource_name": "PtShGgAdi3",
"resource_type": "aws_db_instance",
"file": "main.tf",
"root_path": "./",
"line": 39
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"resource_name": "PtShGgAdi3",
"resource_type": "aws_db_instance",
"file": "main.tf",
"root_path": "./",
"line": 39
}
],
Expand Down
8 changes: 8 additions & 0 deletions test/e2e/scan/golden/rules_filtering/skip_single_rule.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"resource_name": "PtShGgAdi3",
"resource_type": "aws_db_instance",
"file": "main.tf",
"root_path": "./",
"line": 39
},
{
Expand All @@ -21,6 +22,7 @@
"resource_name": "PtShGgAdi6",
"resource_type": "aws_db_instance",
"file": "main.tf",
"root_path": "./",
"line": 82
},
{
Expand All @@ -32,6 +34,7 @@
"resource_name": "PtShGgAdi2",
"resource_type": "aws_db_instance",
"file": "main.tf",
"root_path": "./",
"line": 25
},
{
Expand All @@ -43,6 +46,7 @@
"resource_name": "PtShGgAdi5",
"resource_type": "aws_db_instance",
"file": "main.tf",
"root_path": "./",
"line": 69
},
{
Expand All @@ -54,6 +58,7 @@
"resource_name": "PtShGgAdi3",
"resource_type": "aws_db_instance",
"file": "main.tf",
"root_path": "./",
"line": 39
},
{
Expand All @@ -65,6 +70,7 @@
"resource_name": "PtShGgAdi4",
"resource_type": "aws_db_instance",
"file": "main.tf",
"root_path": "./",
"line": 55
},
{
Expand All @@ -76,6 +82,7 @@
"resource_name": "PtShGgAdi1",
"resource_type": "aws_db_instance",
"file": "main.tf",
"root_path": "./",
"line": 10
},
{
Expand All @@ -87,6 +94,7 @@
"resource_name": "PtShGgAdi3",
"resource_type": "aws_db_instance",
"file": "main.tf",
"root_path": "./",
"line": 39
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Violation Details -

Description : Enable AWS AMI Encryption
File : main.tf
Root Path : ./
Line : 5
Severity : MEDIUM

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Violation Details -

Description : Enable AWS AMI Encryption
File : main.tf
Root Path : ./
Line : 5
Severity : MEDIUM
Rule Name : amiNotEncrypted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"resource_name": "awsAmiEncrypted",
"resource_type": "aws_ami",
"file": "main.tf",
"root_path": "./",
"line": 5
}
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"results": {
"violations": [
{
"rule_name": "amiNotEncrypted",
"description": "Enable AWS AMI Encryption",
"rule_id": "AWS.EC2.Encryption\u0026KeyManagement.Medium.0688",
"severity": "MEDIUM",
"category": "Encryption \u0026 KeyManagement",
"resource_name": "awsAmiEncrypted",
"resource_type": "aws_ami",
"file": "subFolder1/subFolder2/main.tf",
"root_path": "subFolder1/subFolder2",
"line": 5
}
],
"skipped_violations": null,
"scan_summary": {
"file/folder": "/Users/pankajpatil/go/src/github.com/patilpankaj212/terrascan/test/e2e/test_data/iac/terraform_recursive",
"iac_type": "terraform",
"scanned_at": "2021-04-18 12:45:51.597994 +0000 UTC",
"policies_validated": 7,
"violated_policies": 1,
"low": 0,
"medium": 1,
"high": 0
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<results>
<passed_rules></passed_rules>
<violations>
<violation rule_name="amiNotEncrypted" description="Enable AWS AMI Encryption" rule_id="AWS.EC2.Encryption&amp;KeyManagement.Medium.0688" severity="MEDIUM" category="Encryption &amp; KeyManagement" resource_name="awsAmiEncrypted" resource_type="aws_ami" file="main.tf" line="5"></violation>
<violation rule_name="amiNotEncrypted" description="Enable AWS AMI Encryption" rule_id="AWS.EC2.Encryption&amp;KeyManagement.Medium.0688" severity="MEDIUM" category="Encryption &amp; KeyManagement" resource_name="awsAmiEncrypted" resource_type="aws_ami" file="main.tf" root_path="./" line="5"></violation>
</violations>
<skipped_violations></skipped_violations>
<scan_summary file_folder="/Users/apple/go/src/github.com/patilpankaj212/terrascan/test/e2e/test_data/iac/aws/aws_ami_violation" iac_type="terraform" scanned_at="2021-03-02 15:46:23.06028 +0000 UTC" policies_validated="7" violated_policies="1" low="0" medium="1" high="0"></scan_summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ results:
resource_name: awsAmiEncrypted
resource_type: aws_ami
file: main.tf
root_path: ./
line: 5
skipped_violations: []
scan_summary:
Expand Down
Loading

0 comments on commit d3ff6be

Please sign in to comment.