Skip to content

Commit

Permalink
fix linter complains: param order, field names, extra line,...
Browse files Browse the repository at this point in the history
  • Loading branch information
ramyadmz committed Nov 13, 2024
1 parent f079f97 commit 7eb261e
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,29 @@ 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 []
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 []
Expand All @@ -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"
Expand All @@ -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
###############################################################################
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,41 @@ 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
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"
description "Select FlexeraOne OAuth2 credentials"
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
Expand All @@ -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

Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ policy 'itam_policy' do
end
end


###############################################################################
# Escalations
###############################################################################
Expand Down
1 change: 0 additions & 1 deletion saas/office365/security_alerts/o365_security_alerts.pt
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 0 additions & 2 deletions security/aws/rds_unencrypted/aws_unencrypted_rds_instances.pt
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 7eb261e

Please sign in to comment.