From 7eb261e338e99bcd86baa9d7e137a5f8323c8ba9 Mon Sep 17 00:00:00 2001 From: ramyadmz Date: Tue, 12 Nov 2024 18:51:57 -0800 Subject: [PATCH] fix linter complains: param order, field names, extra line,... --- ...ces_not_running_flexnet_inventory_agent.pt | 65 ++++++++++--------- .../expiring_licenses.pt | 39 +++++++++-- .../ignored_recent_inventory_dates.pt | 1 - .../security_alerts/o365_security_alerts.pt | 1 - .../aws_publicly_accessible_rds_instances.pt | 2 - .../aws_unencrypted_rds_instances.pt | 2 - 6 files changed, 67 insertions(+), 43 deletions(-) diff --git a/compliance/azure/instances_without_fnm_agent/azure_instances_not_running_flexnet_inventory_agent.pt b/compliance/azure/instances_without_fnm_agent/azure_instances_not_running_flexnet_inventory_agent.pt index 1219e613e..28bd06482 100644 --- a/compliance/azure/instances_without_fnm_agent/azure_instances_not_running_flexnet_inventory_agent.pt +++ b/compliance/azure/instances_without_fnm_agent/azure_instances_not_running_flexnet_inventory_agent.pt @@ -15,11 +15,12 @@ info( ) ############################################################################### -# User inputs +# Parameters ############################################################################### parameter "param_email" do type "list" + category "Policy Settings" label "Email addresses to notify" description "Email addresses of the recipients you wish to notify when new incidents are created." default [] @@ -27,13 +28,16 @@ end parameter "param_azure_endpoint" do type "string" + category "Policy Settings" label "Azure Endpoint" + description "Select the API endpoint to use for Azure. Use default value of management.azure.com unless using Azure China." allowed_values "management.azure.com", "management.chinacloudapi.cn" default "management.azure.com" end parameter "param_subscriptions_list" do label "Subscription Allowed List" + category "Filters" type "list" description "Allowed Subscriptions, if empty, all subscriptions will be checked" default [] @@ -49,6 +53,7 @@ end parameter "param_fnms_host" do type "string" + category "Policy Settings" label "FlexNet Manager host" description "Flexera One FlexNet Manager host" allowed_values "slo.app.flexera.com", "slo.app.flexera.eu", "slo.app.flexera.au", "slo-uat.app.flexera.com", "slo-uat.app.flexera.eu", "slo-uat.app.flexera.au" @@ -57,23 +62,11 @@ end parameter "param_report_id" do type "string" + category "Policy Settings" label "FNMS Report ID" description "FlexNet manager Custom View ID." end -############################################################################### -# Pagination -############################################################################### - -pagination "pagination_azure" do - get_page_marker do - body_path "nextLink" - end - set_page_marker do - uri true - end -end - ############################################################################### # Authentication ############################################################################### @@ -94,7 +87,20 @@ credentials "auth_flexera" do end ############################################################################### -# Datasources +# Pagination +############################################################################### + +pagination "pagination_azure" do + get_page_marker do + body_path "nextLink" + end + set_page_marker do + uri true + end +end + +############################################################################### +# Datasources & Scripts ############################################################################### datasource "ds_subscriptions" do @@ -176,9 +182,9 @@ end datasource "ds_fnms_report" do request do auth $auth_flexera - host $param_fnms_host verb "POST" scheme "https" + host $param_fnms_host path "/ManageSoftServices/ComplianceAPIService/ComplianceAPIService.asmx" query "orgid", to_s(rs_org_id) # Must convert rs_org_id to string otherwise query param does not get set header "Content-Type", "text/xml;charset=utf-8" @@ -224,27 +230,16 @@ script "js_format_instances", type: "javascript" do EOS end -############################################################################### -# Escalations -############################################################################### - -escalation "esc_email" do - automatic true - label "Send Email" - description "Send incident email" - email $param_email -end - ############################################################################### # Policy ############################################################################### -policy "policy_long_running_instances" do +policy "pol_long_running_instances" do validate $ds_formatted_instances do summary_template "{{ rs_project_name }} (Account ID: {{ rs_project_id }}): {{len data }} is missing in FlexNet Manager." - escalate $esc_email # Policy check fails and incident is created only if data is not empty and the Parent Policy has not been terminated check logic_or($ds_parent_policy_terminated, eq(size(data), 0)) + escalate $esc_email export do resource_level true field "subscriptionName" do @@ -273,6 +268,17 @@ policy "policy_long_running_instances" do end end +############################################################################### +# Escalations +############################################################################### + +escalation "esc_email" do + automatic true + label "Send Email" + description "Send incident email" + email $param_email +end + ############################################################################### # Meta Policy [alpha] # Not intended to be modified or used by policy developers @@ -294,7 +300,6 @@ datasource "ds_get_policy" do end end - datasource "ds_parent_policy_terminated" do run_script $js_decide_if_self_terminate, $ds_get_policy, policy_id, meta_parent_policy_id end diff --git a/compliance/flexera/fnms/fnms_licenses_expiring/expiring_licenses.pt b/compliance/flexera/fnms/fnms_licenses_expiring/expiring_licenses.pt index b1794431a..5f7476b4d 100644 --- a/compliance/flexera/fnms/fnms_licenses_expiring/expiring_licenses.pt +++ b/compliance/flexera/fnms/fnms_licenses_expiring/expiring_licenses.pt @@ -14,8 +14,13 @@ info( hide_skip_approvals: "true" ) +############################################################################### +# Parameters +############################################################################### + parameter "param_expiring" do type "number" + category "Policy Settings" label "Time Period of Expiration" description "Number of days out to search for license expiration" default 90 @@ -23,10 +28,15 @@ end parameter "param_email" do type "list" + category "Policy Settings" label "Email addresses of the recipients you wish to notify" description "A list of email addresse(s) to notify" end +############################################################################### +# Authentication +############################################################################### + credentials "auth_flexeraone" do schemes "oauth2" label "flexera" @@ -34,7 +44,11 @@ credentials "auth_flexeraone" do tags "provider=flexera" end -pagination "itam_pagination" do +############################################################################### +# Pagination +############################################################################### + +pagination "pagination_itam" do get_page_marker do body_path jq(response, "if .total == 0 then null else .offset + 10000 end") end @@ -43,16 +57,20 @@ pagination "itam_pagination" do end end +############################################################################### +# Datasources & Scripts +############################################################################### + datasource "ds_licenses" do request do auth $auth_flexeraone host join(["api.", get(1, split(f1_app_host, "app."))]) path join(["/fnms/v1/orgs/", rs_org_id, "/license-attributes"]) - header "Api-Version", "0.1" - header "User-Agent", "RS Policies" query "status", "Active" query "limit", "10000" - pagination $itam_pagination + header "Api-Version", "0.1" + header "User-Agent", "RS Policies" + pagination $pagination_itam end end @@ -82,11 +100,15 @@ script "js_check_date", type: "javascript" do EOF end +############################################################################### +# Policy +############################################################################### + policy 'itam_policy' do validate_each $ds_check_date do summary_template 'IT Asset - Expiring Licenses' - escalate $send_report check eq(to_n(val(item,"expiring")),0) + escalate $esc_send_report export do field "licenseId" field "publisher" @@ -97,12 +119,15 @@ policy 'itam_policy' do field "licenseDuration" field "licenseType" field "expiryDate" - end end end -escalation "send_report" do +############################################################################### +# Escalations +############################################################################### + +escalation "esc_send_report" do automatic true label "Send Email" description "Send incident email" diff --git a/compliance/flexera/fnms/ignored_recent_inventory_dates/ignored_recent_inventory_dates.pt b/compliance/flexera/fnms/ignored_recent_inventory_dates/ignored_recent_inventory_dates.pt index 586624785..6d2c9bd1d 100644 --- a/compliance/flexera/fnms/ignored_recent_inventory_dates/ignored_recent_inventory_dates.pt +++ b/compliance/flexera/fnms/ignored_recent_inventory_dates/ignored_recent_inventory_dates.pt @@ -124,7 +124,6 @@ policy 'itam_policy' do end end - ############################################################################### # Escalations ############################################################################### diff --git a/saas/office365/security_alerts/o365_security_alerts.pt b/saas/office365/security_alerts/o365_security_alerts.pt index 712d1b9e7..ceb8ffd80 100644 --- a/saas/office365/security_alerts/o365_security_alerts.pt +++ b/saas/office365/security_alerts/o365_security_alerts.pt @@ -99,7 +99,6 @@ script "js_alerts", type: "javascript" do var request = { auth: "auth_azure_graph", - verb: "GET", host: "graph.microsoft.com", path: "/v1.0/security/alerts_v2", query_params: { "filter": filter }, diff --git a/security/aws/rds_publicly_accessible/aws_publicly_accessible_rds_instances.pt b/security/aws/rds_publicly_accessible/aws_publicly_accessible_rds_instances.pt index 0abea8b74..c6e17e08e 100644 --- a/security/aws/rds_publicly_accessible/aws_publicly_accessible_rds_instances.pt +++ b/security/aws/rds_publicly_accessible/aws_publicly_accessible_rds_instances.pt @@ -296,7 +296,6 @@ script "js_rds_instances_set", type: "javascript" do var request = { auth: "auth_aws", host: "rds." + region + ".amazonaws.com", - verb: "GET", path: "/", headers: { "User-Agent": "RS Policies", @@ -339,7 +338,6 @@ script "js_resource_tags", type: "javascript" do var request = { auth: "auth_aws", host: "rds." + region + ".amazonaws.com", - verb: "GET", path: "/", headers: { "User-Agent": "RS Policies", diff --git a/security/aws/rds_unencrypted/aws_unencrypted_rds_instances.pt b/security/aws/rds_unencrypted/aws_unencrypted_rds_instances.pt index 52a586cf1..b68601548 100644 --- a/security/aws/rds_unencrypted/aws_unencrypted_rds_instances.pt +++ b/security/aws/rds_unencrypted/aws_unencrypted_rds_instances.pt @@ -302,7 +302,6 @@ script "js_rds_instances_set", type: "javascript" do var request = { auth: "auth_aws", host: "rds." + region + ".amazonaws.com", - verb: "GET", path: "/", headers: { "User-Agent": "RS Policies", @@ -345,7 +344,6 @@ script "js_resource_tags", type: "javascript" do var request = { auth: "auth_aws", host: "rds." + region + ".amazonaws.com", - verb: "GET", path: "/", headers: { "User-Agent": "RS Policies",