Skip to content

Commit

Permalink
feat(terraform): add CKV NCP rule about vpc volume encryption. (#3629)
Browse files Browse the repository at this point in the history
* [22.09.27][추가] CKV_NCP_1

* [22.09.27][추가] CKV_NCP_2

* Apply suggestions from code review

Co-authored-by: Anton Grübel <[email protected]>

* Apply suggestions from code review

Co-authored-by: Anton Grübel <[email protected]>

* Apply suggestions from code review

Co-authored-by: Anton Grübel <[email protected]>

* Create main.yml

* [22.09.28][수정] Lint test

* Delete main.yml

* [22.09.29][수정]testcode 수정

* [22.09.29][수정] 테스트 코드 수정

* [22.09.29][수정] 테스트코드 수정

* [22.09.29][수정] add test resource for 'ncloud_access_control_group_rule'

* [22.10.03][add]CKV_AWS_3 RULE

* [22.10.04][add]CKV_NCP_4, CKV_NCP_5 RULE

* [22.10.04][add] NCP ACG Inbound for port 22, 3389

* [22.10.04][add] NCP NACL for port 20, 21, 22, 3389

* [22.10.05][modify] LBSecureProtocols.py

* [22.10.05][add] NCP ACGIngress & Egress Check

* [22.10.06][add] NCP rules about ACG, LB, NACL, Encrpytion

* [22.10.06][refactor] rename rules

* [22.10.07][add] NCP NACLPortCheck

* [22.10.08][refactor] modify rule id 77 to 14

* [22.10.09][refactor] modify branch for ncp tf 7

* [22.10.03][add]CKV_AWS_3 RULE

* [22.10.18][fix] fix ncp rule 2 id

* [22.10.19][refactor] adjust ncp rule-7

* [22.10.24][refactor] adjust change

Co-authored-by: pj991207 <[email protected]>
Co-authored-by: Anton Grübel <[email protected]>
Co-authored-by: taeng0204 <[email protected]>
Co-authored-by: yudam <[email protected]>
  • Loading branch information
5 people authored Oct 26, 2022
1 parent f6dc072 commit 8adec19
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

from checkov.common.models.enums import CheckCategories
from checkov.terraform.checks.resource.base_resource_value_check import BaseResourceValueCheck


class LaunchConfigurationEncryptionVPC(BaseResourceValueCheck):
def __init__(self):
name = "Ensure Basic Block storage is encrypted."
id = "CKV_NCP_7"
supported_resources = ('ncloud_launch_configuration',)
categories = (CheckCategories.ENCRYPTION,)
super().__init__(name=name, id=id, categories=categories, supported_resources=supported_resources)

def get_inspected_key(self):
return "is_encrypted_volume"


check = LaunchConfigurationEncryptionVPC()
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
resource "ncloud_launch_configuration" "pass" {
name = "my-lc"
server_image_product_code = "SW.VSVR.OS.LNX64.CNTOS.0703.B050"
server_product_code = "SVR.VSVR.HICPU.C002.M004.NET.SSD.B050.G002"
is_encrypted_volume = true
}
resource "ncloud_launch_configuration" "fail" {
name = "my-lc"
server_image_product_code = "SW.VSVR.OS.LNX64.CNTOS.0703.B050"
server_product_code = "SVR.VSVR.HICPU.C002.M004.NET.SSD.B050.G002"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import unittest
from pathlib import Path

from checkov.runner_filter import RunnerFilter
from checkov.terraform.checks.resource.ncp.LaunchConfigurationEncryptionVPC import check
from checkov.terraform.runner import Runner


class TestLaunchConfigurationCheck(unittest.TestCase):
def test(self):
# given
test_files_dir = Path(__file__).parent / "example_LaunchConfigurationEncryptionVPC"

# when
report = Runner().run(root_folder=str(test_files_dir), runner_filter=RunnerFilter(checks=[check.id]))

# then
summary = report.get_summary()

passing_resources = {
"ncloud_launch_configuration.pass",
}
failing_resources = {
"ncloud_launch_configuration.fail",
}

passed_check_resources = {c.resource for c in report.passed_checks}
failed_check_resources = {c.resource for c in report.failed_checks}

self.assertEqual(summary["passed"], 1)
self.assertEqual(summary["failed"], 1)
self.assertEqual(summary["skipped"], 0)
self.assertEqual(summary["parsing_errors"], 0)

self.assertEqual(passing_resources, passed_check_resources)
self.assertEqual(failing_resources, failed_check_resources)


if __name__ == "__main__":
unittest.main()

0 comments on commit 8adec19

Please sign in to comment.