Skip to content

Conversation

@brodriguez-opennebula
Copy link
Contributor

Description

Add prometheus power collector

Following metrics are created if available

  • opennebula_host_power_consumption_uW: total microwatts used by the
    OpenNebula host. It is just computed at the RAPL domain level (real
    power usage is higher). This number correlates with the power usage.
  • opennebula_vm_power_consumption_uW: microwatts used by each VM
    proportionally
  • opennebula_vmproc_power_consumption_uW: microwatts for each process
    on the virtual machine (please, check how to make them available)
  • opennebula_vmproc_cpu_time_percent: percentage of real CPU (not
    vCPU) used per process

Requirements for the first two metrics:

  • Scaphandre must be
    running on each host with a prometheus exporter
  • The host variable SCAPHANDRE_PORT must be defined with the port
    where the scaphandre is running

Requirements for the four metrics:

  • The same for the first two metrics
  • The VM must have running qemu guest agent and it must allow the
    execution of commands
  • get_proc_ticks must be on each VM on the path
    /var/lib/one-context/get_proc_ticks

get_proc_ticks is available in github

Branches to which this PR applies

  • master
  • one-6.10-ce

  • Check this if this PR should not be squashed

onenhansen and others added 30 commits September 2, 2024 17:11
Signed-off-by: Neal Hansen <nhansen@opennebula.io>
Co-authored-by: Tino Vázquez <cvazquez@opennebula.io>
(cherry picked from commit 02e0fce)
Fix is the same applied here: c9742ad3d798e3c (use to_s to prevent
nil.upcase calls)

(cherry picked from commit 4c7f6dc)
* Schemas validated by online tool
* Ambiguity errors not solved

(cherry picked from commit cd9eb49)
* F #6505: Fix volatile disk backup and restore

* F #6578: Skip backup of CDROM

(cherry picked from commit c8c66b1)
Signed-off-by: dcarracedo <dcarracedo@opennebula.io>
(cherry picked from commit 4a1abef)
Add a check before dereferencing the group roles pointer.

(cherry picked from commit 48bab98)
(cherry picked from commit 1607b4a)
* Cleanup oned in case of initialization error

* Fix monitoring after onemonitord restart. The code includes a "hook" point in case a driver is re-started so custom code can be executed. InformationManager sends the list of hosts and raft status in this case.

* B #5801: Update error msg, in case of duplicated drivers

(cherry picked from commit 7b07def)
* Fixes 02e0fce

(cherry picked from commit be6bcf8)
* Now instantiates the correct number of instances specified for a
  service ServiceTemplate
* Default number of instances set to 1

Signed-off-by: Victor Hansson <vhansson@opennebula.io>
(cherry picked from commit 212aa91)
in onevm for a specific disk

Signed-off-by: ArnauGabrielAtienza <agabriel@opennebula.io>
(cherry picked from commit 263cba6)
Signed-off-by: ArnauGabrielAtienza <agabriel@opennebula.io>
(cherry picked from commit a95a94b)
Signed-off-by: dcarracedo <dcarracedo@opennebula.io>
Co-authored-by: Tino Vázquez <cvazquez@opennebula.io>
(cherry picked from commit b2fe5a3)
* B #6505: follow-up fix for Ceph bk/restore (#3212)

Signed-off-by: Guillermo Ramos <gramos@opennebula.io>
Co-authored-by: Pavel Czerný <pczerny@opennebula.io>
(cherry picked from commit c8d28ad)
using the finder in tables

(cherry picked from commit f01175b)
Metric is in bytes, MB was published
* Fix Host NUMA nodes after VM migration
* Move template parsing to HostShareCapacity

+ add warning about unsafe pointer usage

(cherry picked from commit 0cde7d9)
* It looks like `onedb purge-history` sometimes fails to delete some history records.
* Delete all history records with SEQ greater then VM/HISTORY_RECORDS/HISTORY/SEQ, which should be the last record

(cherry picked from commit a3c4776)
* Now displays hostname next to the host in the card view
* Also displays hostname in the list view

Signed-off-by: Victor Hansson <vhansson@opennebula.io>
Signed-off-by: dcarracedo <dcarracedo@opennebula.io>
(cherry picked from commit 1fcb2ba)
[LABELS, onDeleteLabel, onClickLabel]
)

return <MultipleTags tags={labels} truncateText={10} />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

A potential Cross-Site Scripting (XSS) vulnerability has been identified, where untrusted input is being reflected in the response without proper sanitization. This can allow an attacker to inject and execute malicious scripts in the user's browser, potentially compromising sensitive data or application behavior. To mitigate this risk, it is strongly recommended to sanitize or encode all user input before rendering it in the DOM or returning it in a response. Commonly used methods include DOMPurify.sanitize(), encodeURIComponent(), escape(), etc., depending on the use case and framework in use. Learn more - https://cwe.mitre.org/data/definitions/79.html

accessor: (template) => {
const { color: stateColor, name: stateName } = getState(template)

return <StatusCircle color={stateColor} tooltip={stateName} />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

A potential Cross-Site Scripting (XSS) vulnerability has been identified, where untrusted input is being reflected in the response without proper sanitization. This can allow an attacker to inject and execute malicious scripts in the user's browser, potentially compromising sensitive data or application behavior. To mitigate this risk, it is strongly recommended to sanitize or encode all user input before rendering it in the DOM or returning it in a response. Commonly used methods include DOMPurify.sanitize(), encodeURIComponent(), escape(), etc., depending on the use case and framework in use. Learn more - https://cwe.mitre.org/data/definitions/79.html

const { percentCpuUsed, percentCpuLabel, colorCpu } =
getAllocatedInfo(host)

return (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

A potential Cross-Site Scripting (XSS) vulnerability has been identified, where untrusted input is being reflected in the response without proper sanitization. This can allow an attacker to inject and execute malicious scripts in the user's browser, potentially compromising sensitive data or application behavior. To mitigate this risk, it is strongly recommended to sanitize or encode all user input before rendering it in the DOM or returning it in a response. Commonly used methods include DOMPurify.sanitize(), encodeURIComponent(), escape(), etc., depending on the use case and framework in use. Learn more - https://cwe.mitre.org/data/definitions/79.html

accessor: (template) => {
const { color: stateColor, name: stateName } = getState(template)

return <StatusCircle color={stateColor} tooltip={stateName} />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

A potential Cross-Site Scripting (XSS) vulnerability has been identified, where untrusted input is being reflected in the response without proper sanitization. This can allow an attacker to inject and execute malicious scripts in the user's browser, potentially compromising sensitive data or application behavior. To mitigate this risk, it is strongly recommended to sanitize or encode all user input before rendering it in the DOM or returning it in a response. Commonly used methods include DOMPurify.sanitize(), encodeURIComponent(), escape(), etc., depending on the use case and framework in use. Learn more - https://cwe.mitre.org/data/definitions/79.html

displayName: stateDisplayName,
} = getState(vm)

return (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

A potential Cross-Site Scripting (XSS) vulnerability has been identified, where untrusted input is being reflected in the response without proper sanitization. This can allow an attacker to inject and execute malicious scripts in the user's browser, potentially compromising sensitive data or application behavior. To mitigate this risk, it is strongly recommended to sanitize or encode all user input before rendering it in the DOM or returning it in a response. Commonly used methods include DOMPurify.sanitize(), encodeURIComponent(), escape(), etc., depending on the use case and framework in use. Learn more - https://cwe.mitre.org/data/definitions/79.html

const { percentMemUsed, percentMemLabel, colorMem } =
getAllocatedInfo(host)

return (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

A potential Cross-Site Scripting (XSS) vulnerability has been identified, where untrusted input is being reflected in the response without proper sanitization. This can allow an attacker to inject and execute malicious scripts in the user's browser, potentially compromising sensitive data or application behavior. To mitigate this risk, it is strongly recommended to sanitize or encode all user input before rendering it in the DOM or returning it in a response. Commonly used methods include DOMPurify.sanitize(), encodeURIComponent(), escape(), etc., depending on the use case and framework in use. Learn more - https://cwe.mitre.org/data/definitions/79.html

accessor: (template) => {
const { color: stateColor, name: stateName } = getState(template)

return <StatusCircle color={stateColor} tooltip={stateName} />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

A potential Cross-Site Scripting (XSS) vulnerability has been identified, where untrusted input is being reflected in the response without proper sanitization. This can allow an attacker to inject and execute malicious scripts in the user's browser, potentially compromising sensitive data or application behavior. To mitigate this risk, it is strongly recommended to sanitize or encode all user input before rendering it in the DOM or returning it in a response. Commonly used methods include DOMPurify.sanitize(), encodeURIComponent(), escape(), etc., depending on the use case and framework in use. Learn more - https://cwe.mitre.org/data/definitions/79.html

accessor: (service) => {
const { color: stateColor, name: stateName } = getState(service)

return <StatusCircle color={stateColor} tooltip={stateName} />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

A potential Cross-Site Scripting (XSS) vulnerability has been identified, where untrusted input is being reflected in the response without proper sanitization. This can allow an attacker to inject and execute malicious scripts in the user's browser, potentially compromising sensitive data or application behavior. To mitigate this risk, it is strongly recommended to sanitize or encode all user input before rendering it in the DOM or returning it in a response. Commonly used methods include DOMPurify.sanitize(), encodeURIComponent(), escape(), etc., depending on the use case and framework in use. Learn more - https://cwe.mitre.org/data/definitions/79.html

accessor: (vm) => {
const { color: stateColor, name: stateName } = getState(vm)

return <StatusCircle color={stateColor} tooltip={stateName} />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

A potential Cross-Site Scripting (XSS) vulnerability has been identified, where untrusted input is being reflected in the response without proper sanitization. This can allow an attacker to inject and execute malicious scripts in the user's browser, potentially compromising sensitive data or application behavior. To mitigate this risk, it is strongly recommended to sanitize or encode all user input before rendering it in the DOM or returning it in a response. Commonly used methods include DOMPurify.sanitize(), encodeURIComponent(), escape(), etc., depending on the use case and framework in use. Learn more - https://cwe.mitre.org/data/definitions/79.html

accessor: (vm) => {
const { color: stateColor, name: stateName } = getState(vm)

return <StatusCircle color={stateColor} tooltip={stateName} />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

A potential Cross-Site Scripting (XSS) vulnerability has been identified, where untrusted input is being reflected in the response without proper sanitization. This can allow an attacker to inject and execute malicious scripts in the user's browser, potentially compromising sensitive data or application behavior. To mitigate this risk, it is strongly recommended to sanitize or encode all user input before rendering it in the DOM or returning it in a response. Commonly used methods include DOMPurify.sanitize(), encodeURIComponent(), escape(), etc., depending on the use case and framework in use. Learn more - https://cwe.mitre.org/data/definitions/79.html

accessor: (vm) => {
const { color: stateColor, name: stateName } = getState(vm)

return <StatusCircle color={stateColor} tooltip={stateName} />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

A potential Cross-Site Scripting (XSS) vulnerability has been identified, where untrusted input is being reflected in the response without proper sanitization. This can allow an attacker to inject and execute malicious scripts in the user's browser, potentially compromising sensitive data or application behavior. To mitigate this risk, it is strongly recommended to sanitize or encode all user input before rendering it in the DOM or returning it in a response. Commonly used methods include DOMPurify.sanitize(), encodeURIComponent(), escape(), etc., depending on the use case and framework in use. Learn more - https://cwe.mitre.org/data/definitions/79.html

const capacity = useMemo(() => getCapacityInfo(template), [template])
const { percentOfUsed, percentLabel } = capacity

return (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

A potential Cross-Site Scripting (XSS) vulnerability has been identified, where untrusted input is being reflected in the response without proper sanitization. This can allow an attacker to inject and execute malicious scripts in the user's browser, potentially compromising sensitive data or application behavior. To mitigate this risk, it is strongly recommended to sanitize or encode all user input before rendering it in the DOM or returning it in a response. Commonly used methods include DOMPurify.sanitize(), encodeURIComponent(), escape(), etc., depending on the use case and framework in use. Learn more - https://cwe.mitre.org/data/definitions/79.html

const leasesInfo = useMemo(() => getLeasesInfo(template), [template])
const { percentOfUsed, percentLabel } = leasesInfo

return (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

A potential Cross-Site Scripting (XSS) vulnerability has been identified, where untrusted input is being reflected in the response without proper sanitization. This can allow an attacker to inject and execute malicious scripts in the user's browser, potentially compromising sensitive data or application behavior. To mitigate this risk, it is strongly recommended to sanitize or encode all user input before rendering it in the DOM or returning it in a response. Commonly used methods include DOMPurify.sanitize(), encodeURIComponent(), escape(), etc., depending on the use case and framework in use. Learn more - https://cwe.mitre.org/data/definitions/79.html

accessor: (vm) => {
const { color: stateColor, name: stateName } = getState(vm)

return <StatusCircle color={stateColor} tooltip={stateName} />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

A potential Cross-Site Scripting (XSS) vulnerability has been identified, where untrusted input is being reflected in the response without proper sanitization. This can allow an attacker to inject and execute malicious scripts in the user's browser, potentially compromising sensitive data or application behavior. To mitigate this risk, it is strongly recommended to sanitize or encode all user input before rendering it in the DOM or returning it in a response. Commonly used methods include DOMPurify.sanitize(), encodeURIComponent(), escape(), etc., depending on the use case and framework in use. Learn more - https://cwe.mitre.org/data/definitions/79.html

row
const { key, ...rowProps } = getRowProps()

return (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

A potential Cross-Site Scripting (XSS) vulnerability has been identified, where untrusted input is being reflected in the response without proper sanitization. This can allow an attacker to inject and execute malicious scripts in the user's browser, potentially compromising sensitive data or application behavior. To mitigate this risk, it is strongly recommended to sanitize or encode all user input before rendering it in the DOM or returning it in a response. Commonly used methods include DOMPurify.sanitize(), encodeURIComponent(), escape(), etc., depending on the use case and framework in use. Learn more - https://cwe.mitre.org/data/definitions/79.html

const capacity = useMemo(() => getCapacityInfo(template), [template])
const { percentOfUsed, percentLabel } = capacity

return (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

A potential Cross-Site Scripting (XSS) vulnerability has been identified, where untrusted input is being reflected in the response without proper sanitization. This can allow an attacker to inject and execute malicious scripts in the user's browser, potentially compromising sensitive data or application behavior. To mitigate this risk, it is strongly recommended to sanitize or encode all user input before rendering it in the DOM or returning it in a response. Commonly used methods include DOMPurify.sanitize(), encodeURIComponent(), escape(), etc., depending on the use case and framework in use. Learn more - https://cwe.mitre.org/data/definitions/79.html

id: 'consoles',
accessor: (vm) => (
<>
{CONNECTION_TYPES.map((connectionType) => (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

A potential Cross-Site Scripting (XSS) vulnerability has been identified, where untrusted input is being reflected in the response without proper sanitization. This can allow an attacker to inject and execute malicious scripts in the user's browser, potentially compromising sensitive data or application behavior. To mitigate this risk, it is strongly recommended to sanitize or encode all user input before rendering it in the DOM or returning it in a response. Commonly used methods include DOMPurify.sanitize(), encodeURIComponent(), escape(), etc., depending on the use case and framework in use. Learn more - https://cwe.mitre.org/data/definitions/79.html

diskModifications[key].__delete__
) {
delete acc[key]
} else if (key === 'SIZE' && diskModifications.SIZEUNIT) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Potential hardcoded credential detected. This code may contain sensitive
data such as passwords or API keys embedded directly in the
source. Hardcoded credentials can be extracted and misused, leading to
unauthorized access to systems or data breaches. To remediate this, store
secrets in environment variables or use a secrets management tool like AWS
Secrets Manager, Azure Key Vault, or HashiCorp Vault. Avoid committing
credentials to version control. For best practices, refer to -
https://owasp.org/www-community/vulnerabilities/Use_of_hard-coded_password

Limitations: May not detect dynamically constructed credentials, credentials
in template literals with variables, or obfuscated/encoded credentials that
don't match standard patterns. Test files are excluded from detection.

if volatile?
@source = nil
@clone = nil
@rbd_image = "#{@pool}/one-sys-#{@vmid}-#{id}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

A cross-site scripting (XSS) vulnerability was detected. User-controlled data is being output without proper sanitization, allowing an attacker to inject malicious scripts. This could lead to session hijacking, malware installation, or phishing attacks. Always sanitize and encode user inputs before including them in the output, using context-appropriate encoding methods. Learn More - https://cwe.mitre.org/data/definitions/79.html.

@clone = disk_xml.elements['CLONE'].text == 'YES'
@rbd_image =
if @clone
"#{@source}-#{@vmid}-#{@id}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

A cross-site scripting (XSS) vulnerability was detected. User-controlled data is being output without proper sanitization, allowing an attacker to inject malicious scripts. This could lead to session hijacking, malware installation, or phishing attacks. Always sanitize and encode user inputs before including them in the output, using context-appropriate encoding methods. Learn More - https://cwe.mitre.org/data/definitions/79.html.

# Configure ports to allow trunk vlans
set_vlan_filter(@nic[:tap], @nic[:vlan_id], vlan_set)

next if bridge_done.include? @nic[:bridge]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Cross-Site Request Forgery (CSRF) protection is disabled or missing in this Ruby web application. This vulnerability occurs when state-changing operations lack proper token validation to verify request authenticity. Attackers can exploit this by tricking authenticated users into unknowingly executing malicious actions like data modification, account changes, or financial transactions through forged requests. Enable CSRF protection by adding 'protect_from_forgery with: :exception' in Rails controllers, using 'authenticity_token' in forms, implementing 'check_csrf!' in Roda routes, or adding 'Rack::Protection::AuthenticityToken' middleware in Sinatra/Rack applications. More information: https://owasp.org/www-community/attacks/csrf

####################################################
@nic = nic
gen_vlan_dev_name
if @bridges[@nic[:bridge]].include? @nic[:vlan_dev]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Cross-Site Request Forgery (CSRF) protection is disabled or missing in this Ruby web application. This vulnerability occurs when state-changing operations lack proper token validation to verify request authenticity. Attackers can exploit this by tricking authenticated users into unknowingly executing malicious actions like data modification, account changes, or financial transactions through forged requests. Enable CSRF protection by adding 'protect_from_forgery with: :exception' in Rails controllers, using 'authenticity_token' in forms, implementing 'check_csrf!' in Roda routes, or adding 'Rack::Protection::AuthenticityToken' middleware in Sinatra/Rack applications. More information: https://owasp.org/www-community/attacks/csrf

# Configure ports to allow trunk vlans
set_vlan_filter(@nic[:tap], nil, vlan_set)

next if bridge_done.include? @nic[:bridge]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Cross-Site Request Forgery (CSRF) protection is disabled or missing in this Ruby web application. This vulnerability occurs when state-changing operations lack proper token validation to verify request authenticity. Attackers can exploit this by tricking authenticated users into unknowingly executing malicious actions like data modification, account changes, or financial transactions through forged requests. Enable CSRF protection by adding 'protect_from_forgery with: :exception' in Rails controllers, using 'authenticity_token' in forms, implementing 'check_csrf!' in Roda routes, or adding 'Rack::Protection::AuthenticityToken' middleware in Sinatra/Rack applications. More information: https://owasp.org/www-community/attacks/csrf

@logger.error "ERROR: #{err.chomp})\n"
@logger.error " [STDOUT] #{rc.stdout.gsub("\n", '\n')}\n" unless opt[:nostdout]
@logger.error " [STDERR] #{rc.stderr.gsub("\n", '\n')}\n" unless opt[:nostderr]
@logger.error err.chomp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Potential log injection detected. Ensure all untrusted input is properly sanitized before logging. Use parameterized logging or validate input against an allow list to prevent log injection vulnerabilities. Consider using a dedicated logging library's built-in sanitization features when available. Learn more - https://cwe.mitre.org/data/definitions/117.html

self.class.scaph_data[host['ID'].to_i] = res.split("\n")
rescue StandardError => e
puts e.message
puts "Error accessing to scaphandre metrics on #{hostname}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Potential log injection detected. Ensure all untrusted input is properly sanitized before logging. Use parameterized logging or validate input against an allow list to prevent log injection vulnerabilities. Consider using a dedicated logging library's built-in sanitization features when available. Learn more - https://cwe.mitre.org/data/definitions/117.html


pid_cmd = issue_command(vm_id, host, cmd, "-s #{interval} -m #{vm_id} -p #{full_power}")
rescue StandardError
puts "Error executing command on VM #{vm_id}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Potential log injection detected. Ensure all untrusted input is properly sanitized before logging. Use parameterized logging or validate input against an allow list to prevent log injection vulnerabilities. Consider using a dedicated logging library's built-in sanitization features when available. Learn more - https://cwe.mitre.org/data/definitions/117.html

puts "Error accessing to scaphandre metrics on #{hostname}"
end
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
puts "Error on #{hostname}:#{port}, is scaphandre running there?"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Potential log injection detected. Ensure all untrusted input is properly sanitized before logging. Use parameterized logging or validate input against an allow list to prevent log injection vulnerabilities. Consider using a dedicated logging library's built-in sanitization features when available. Learn more - https://cwe.mitre.org/data/definitions/117.html


def query_vm_agent(vm_id, query, host = 'localhost')
cmd = "virsh -c 'qemu+ssh://#{host}/system' qemu-agent-command one-#{vm_id} '#{query.to_json}'"
out = `#{cmd}`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Detected a dangerous subshell execution vulnerability where user input is directly used in a shell command without proper sanitisation. This could allow an attacker to inject and execute arbitrary system commands, potentially leading to system compromise or data breach. To remediate, avoid using shell commands with user input when possible, or implement strict input validation and use shell escaping functions like Shellwords.escape(). If shell execution is necessary, consider using a allow list of allowed commands and arguments. Link to more info : https://guides.rubyonrails.org/security.html

restic://*)
eval `$VAR_LOCATION/remotes/datastore/restic_downloader.rb "$FROM" | grep -e '^command=' -e '^clean_command='`
restic://*|restic+rbd://*)
defs=`$VAR_LOCATION/remotes/datastore/restic_downloader.rb "$FROM" | grep -e '^command=' -e '^clean_command='`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

The use of backticks for command substitution in shell scripts can lead to vulnerabilities, quoting issues and nested command complexities. To mitigate this issue, it is recommended to use the more secure '$(...)' syntax for command substitution. This method properly quotes the substituted command, which is more readable, easier to nest, and avoids undefined behaviors related to quoting. Adopting this practice improves code clarity and maintainability. For more information on shell scripting best practices, refer to the GNU Bash Manual (https://www.gnu.org/software/bash/manual/bash.html#Command-Substitution).

rsync://*)
eval `$VAR_LOCATION/remotes/datastore/rsync_downloader.rb "$FROM" | grep -e '^command=' -e '^clean_command='`
rsync://*|rsync+rbd://*)
defs=`$VAR_LOCATION/remotes/datastore/rsync_downloader.rb "$FROM" | grep -e '^command=' -e '^clean_command='`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

The use of backticks for command substitution in shell scripts can lead to vulnerabilities, quoting issues and nested command complexities. To mitigate this issue, it is recommended to use the more secure '$(...)' syntax for command substitution. This method properly quotes the substituted command, which is more readable, easier to nest, and avoids undefined behaviors related to quoting. Adopting this practice improves code clarity and maintainability. For more information on shell scripting best practices, refer to the GNU Bash Manual (https://www.gnu.org/software/bash/manual/bash.html#Command-Substitution).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.