Skip to content

Commit

Permalink
fix linter complains -2
Browse files Browse the repository at this point in the history
  • Loading branch information
ramyadmz committed Nov 13, 2024
1 parent 7eb261e commit 0157515
Show file tree
Hide file tree
Showing 23 changed files with 156 additions and 121 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ parameter "param_azure_endpoint" do
end

parameter "param_subscriptions_list" do
label "Subscription Allowed List"
category "Filters"
type "list"
category "Filters"
label "Subscription Allowed List"
description "Allowed Subscriptions, if empty, all subscriptions will be checked"
default []
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ end
datasource "ds_licenses" do
request do
auth $auth_flexeraone
pagination $pagination_itam
host join(["api.", get(1, split(f1_app_host, "app."))])
path join(["/fnms/v1/orgs/", rs_org_id, "/license-attributes"])
query "status", "Active"
query "limit", "10000"
header "Api-Version", "0.1"
header "User-Agent", "RS Policies"
pagination $pagination_itam
end
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ITAM Ignore Recent Inventory Dates
# ITAM Ignored Recent Inventory Dates

## What It Does

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,41 @@ info(
hide_skip_approvals: "true"
)

###############################################################################
# Parameters
###############################################################################

parameter "param_days_missing" do
type "number"
category "Policy Settings"
label "Days missing while active"
description "Number of missing for a machine to be reported"
default 30
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 @@ -44,16 +58,20 @@ pagination "itam_pagination" do
end
end

###############################################################################
# Datasources & Scripts
###############################################################################

datasource "ds_inventories" do
request do
auth $auth_flexeraone
pagination $pagination_itam
host join(["api.", get(1, split(f1_app_host, "app."))])
path join(["/fnms/v1/orgs/", rs_org_id, "/inventories"])
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"
end
end

Expand All @@ -80,11 +98,15 @@ script "js_check_date", type: "javascript" do
EOF
end

###############################################################################
# Policy
###############################################################################

policy 'itam_policy' do
validate_each $ds_check_date do
summary_template 'ITAM - Missing active machines'
escalate $send_report
check eq(to_n(val(item,"missing")),0)
escalate $esc_send_report
export do
field "name"
field "serialNumber"
Expand Down Expand Up @@ -112,7 +134,11 @@ policy 'itam_policy' do
end
end

escalation "send_report" do
###############################################################################
# Escalations
###############################################################################

escalation "esc_send_report" do
automatic true
label "Send Email"
description "Send incident email"
Expand Down
15 changes: 8 additions & 7 deletions compliance/flexera/fnms/vms_missing_hostid/vms_missing_hostid.pt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ info(

parameter "param_email" do
type "list"
category "Policy Settings"
label "Email addresses of the recipients you wish to notify"
description "A list of email address(es) to notify"
end
Expand All @@ -39,7 +40,7 @@ end
# Pagination
###############################################################################

pagination "itam_pagination" do
pagination "pagination_itam" do
get_page_marker do
body_path jq(response, "if .total == 0 then null else .offset + 10000 end")
end
Expand All @@ -49,19 +50,19 @@ pagination "itam_pagination" do
end

###############################################################################
# Datasources
# Datasources & Scripts
###############################################################################

datasource "ds_inventories" do
request do
auth $auth_flexeraone
pagination $pagination_itam
host join(["api.", get(1, split(f1_app_host, "app."))])
path join(["/fnms/v1/orgs/", rs_org_id, "/inventories"])
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"
end
end

Expand Down Expand Up @@ -96,8 +97,8 @@ end
policy 'itam_policy' do
validate $ds_missing_hostid do
summary_template 'FlexNet Manager - Virtual Machines Without Host ID'
escalate $send_report
check eq(size(data),0)
escalate $esc_send_report
export do
field "name"
field "serialNumber"
Expand Down Expand Up @@ -128,7 +129,7 @@ end
# Escalations
###############################################################################

escalation "send_report" do
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 @@ -563,7 +563,6 @@ script "js_azure_virtual_machines_with_metrics", type: "javascript" do
var request = {
auth: "auth_azure",
host: param_azure_endpoint,
verb: "GET",
path: vmId + "/providers/microsoft.insights/metrics",
query_params: {
"api-version": "2018-01-01",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ script "js_reports", type: "javascript" do
var request = {
auth: "auth_flexera",
host: ds_flexera_api_hosts["flexera"],
verb: "GET",
path: "/finops-analytics/v1/orgs/" + rs_org_id + "/budgets/" + budget.id + "/report",
query_params: {
"dimensions": budget.dimensions || [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ end
#get turbonomic recommendation data
datasource "ds_get_turbonomics_recommendations" do
request do
run_script $js_get_turbonomics_recommendations, $param_turbonomic_host, val($ds_get_turbonomic_token, "access_token")
run_script $js_get_turbonomics_recommendations, val($ds_get_turbonomic_token, "access_token"), $param_turbonomic_host
end
result do
encoding "json"
Expand All @@ -112,7 +112,7 @@ end
##this will potentially be a lot of calls. how to make this more performant
datasource "ds_get_business_units" do
request do
run_script $js_get_business_units, $param_turbonomic_host, val($ds_get_turbonomic_token, "access_token")
run_script $js_get_business_units, val($ds_get_turbonomic_token, "access_token"), $param_turbonomic_host
end
result do
encoding "json"
Expand All @@ -127,7 +127,7 @@ end
##this will potentially be a lot of calls. how to make this more performant
datasource "ds_get_action_details" do
request do
run_script $js_get_action_details, $ds_get_turbonomics_recommendations, $param_turbonomic_host, val($ds_get_turbonomic_token, "access_token")
run_script $js_get_action_details, val($ds_get_turbonomic_token, "access_token"), $ds_get_turbonomics_recommendations, $param_turbonomic_host
end
result do
encoding "json"
Expand Down Expand Up @@ -160,7 +160,7 @@ end

##script using a acquired turbonomic token and pulls hard coded scalable vm data
script "js_get_turbonomics_recommendations", type: "javascript" do
parameters "param_turbonomic_host", "access_token"
parameters "access_token", "param_turbonomic_host"
result "request"
code <<-EOS
var request = {
Expand Down Expand Up @@ -189,11 +189,10 @@ end

## verified that discovered is the only one we need
script "js_get_business_units", type: "javascript" do
parameters "param_turbonomic_host", "access_token"
parameters "access_token", "param_turbonomic_host"
result "request"
code <<-EOS
var request = {
verb: "GET",
host: param_turbonomic_host,
path: "/api/v3/businessunits",
query_params: {
Expand All @@ -209,7 +208,7 @@ EOS
end

script "js_get_action_details", type: "javascript" do
parameters "ds_get_turbonomics_recommendations", "param_turbonomic_host", "access_token"
parameters "access_token", "ds_get_turbonomics_recommendations", "param_turbonomic_host"
result "request"
code <<-EOS
var uuids = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ end
#get turbonomic recommendation data
datasource "ds_get_turbonomics_recommendations" do
request do
run_script $js_get_turbonomics_recommendations, $param_turbonomic_host, val($ds_get_turbonomic_token, "access_token")
run_script $js_get_turbonomics_recommendations, val($ds_get_turbonomic_token, "access_token"), $param_turbonomic_host
end
result do
encoding "json"
Expand All @@ -112,7 +112,7 @@ end
##this will potentially be a lot of calls. how to make this more performant
datasource "ds_get_business_units" do
request do
run_script $js_get_business_units, $param_turbonomic_host, val($ds_get_turbonomic_token, "access_token")
run_script $js_get_business_units, val($ds_get_turbonomic_token, "access_token"), $param_turbonomic_host
end
result do
encoding "json"
Expand All @@ -127,7 +127,7 @@ end
##this will potentially be a lot of calls. how to make this more performant
datasource "ds_get_action_details" do
request do
run_script $js_get_action_details, $ds_get_turbonomics_recommendations, $param_turbonomic_host, val($ds_get_turbonomic_token, "access_token")
run_script $js_get_action_details, val($ds_get_turbonomic_token, "access_token"), $ds_get_turbonomics_recommendations, $param_turbonomic_host
end
result do
encoding "json"
Expand Down Expand Up @@ -160,7 +160,7 @@ end

##script using acquired turbonomic token and pulls hard coded scalable vm data
script "js_get_turbonomics_recommendations", type: "javascript" do
parameters "param_turbonomic_host", "access_token"
parameters "access_token", "param_turbonomic_host"
result "request"
code <<-EOS
//replace cookie every day this is run
Expand Down Expand Up @@ -190,12 +190,11 @@ end

## verified that discovered is the only one we need
script "js_get_business_units", type: "javascript" do
parameters "param_turbonomic_host", "access_token"
parameters "access_token", "param_turbonomic_host"
result "request"
code <<-EOS
//replace cookie every day this is run
var request = {
verb: "GET",
host: param_turbonomic_host,
path: "/api/v3/businessunits",
query_params: {
Expand All @@ -211,7 +210,7 @@ EOS
end

script "js_get_action_details", type: "javascript" do
parameters "ds_get_turbonomics_recommendations", "param_turbonomic_host", "access_token"
parameters "access_token", "ds_get_turbonomics_recommendations", "param_turbonomic_host"
result "request"
code <<-EOS
//replace cookie every day this is run
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ end
#get turbonomic recommendation data
datasource "ds_get_turbonomics_recommendations" do
request do
run_script $js_get_turbonomics_recommendations, $param_turbonomic_host, val($ds_get_turbonomic_token, "access_token")
run_script $js_get_turbonomics_recommendations,val($ds_get_turbonomic_token, "access_token"), $param_turbonomic_host
end
result do
encoding "json"
Expand All @@ -112,7 +112,7 @@ end
##this will potentially be a lot of calls. how to make this more performant
datasource "ds_get_business_units" do
request do
run_script $js_get_business_units, $param_turbonomic_host, val($ds_get_turbonomic_token, "access_token")
run_script $js_get_business_units,val($ds_get_turbonomic_token, "access_token"), $param_turbonomic_host
end
result do
encoding "json"
Expand All @@ -127,7 +127,7 @@ end
##this will potentially be a lot of calls. how to make this more performant
datasource "ds_get_action_details" do
request do
run_script $js_get_action_details, $ds_get_turbonomics_recommendations, $param_turbonomic_host, val($ds_get_turbonomic_token, "access_token")
run_script $js_get_action_details,val($ds_get_turbonomic_token, "access_token"), $ds_get_turbonomics_recommendations, $param_turbonomic_host
end
result do
encoding "json"
Expand Down Expand Up @@ -160,7 +160,7 @@ end

##script using a manually acquired turbonomic cookie and pulls hard coded scalable vm data
script "js_get_turbonomics_recommendations", type: "javascript" do
parameters "param_turbonomic_host", "access_token"
parameters "access_token", "param_turbonomic_host"
result "request"
code <<-EOS
//replace cookie every day this is run
Expand Down Expand Up @@ -190,7 +190,7 @@ end

## verified that discovered is the only one we need
script "js_get_business_units", type: "javascript" do
parameters "param_turbonomic_host", "access_token"
parameters "access_token", "param_turbonomic_host"
result "request"
code <<-EOS
//replace cookie every day this is run
Expand All @@ -211,7 +211,7 @@ EOS
end

script "js_get_action_details", type: "javascript" do
parameters "ds_get_turbonomics_recommendations", "param_turbonomic_host", "access_token"
parameters "access_token", "ds_get_turbonomics_recommendations", "param_turbonomic_host"
result "request"
code <<-EOS
//replace cookie every day this is run
Expand Down
Loading

0 comments on commit 0157515

Please sign in to comment.