-
Notifications
You must be signed in to change notification settings - Fork 302
new plugin for Azure Network Virtual Hub #6172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 6 commits
df9f8b5
eb490a7
4182a01
9485520
b042974
6c49e1b
173290c
fa88947
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -600,6 +600,45 @@ sub azure_get_publicip { | |
| return $self->execute(cmd_options => $cmd_options); | ||
| } | ||
|
|
||
| sub azure_list_resource_metrics_set_cmd { | ||
| my ($self, %options) = @_; | ||
|
|
||
| return if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne ''); | ||
|
|
||
| my $cmd_options = "monitor metrics list-definitions --resource '$options{resource}' --only-show-errors --output json"; | ||
|
|
||
| return $cmd_options; | ||
| } | ||
|
|
||
| sub azure_list_resource_metrics { | ||
| my ($self, %options) = @_; | ||
|
|
||
| my $cmd_options = $self->azure_list_resource_metrics_set_cmd(%options); | ||
| my $raw_results = $self->execute(cmd_options => $cmd_options); | ||
|
|
||
| return $raw_results; | ||
| } | ||
|
|
||
| sub azure_list_virtualhubs_set_cmd { | ||
| my ($self, %options) = @_; | ||
|
|
||
| return if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne ''); | ||
|
|
||
| my $cmd_options = "network vhub list --resource-group '$options{resource_group}' --only-show-errors --output json "; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. azure_list_virtualhubs_set_cmd concatenates $options{resource_group} and $self->{subscription} into a shell command string; avoid direct interpolation into commands (escape or use safe argument passing). Details✨ AI Reasoning 🔧 How do I fix it? Reply |
||
| $cmd_options .= " --subscription '$self->{subscription}'" if (defined($self->{subscription}) && $self->{subscription} ne ''); | ||
|
|
||
| return $cmd_options; | ||
| } | ||
|
|
||
| sub azure_list_virtualhubs { | ||
| my ($self, %options) = @_; | ||
|
|
||
| my $cmd_options = $self->azure_list_virtualhubs_set_cmd(%options); | ||
| my $raw_results = $self->execute(cmd_options => $cmd_options); | ||
|
|
||
| return $raw_results; | ||
| } | ||
|
|
||
| 1; | ||
|
|
||
| __END__ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| # | ||
| # Copyright 2024 Centreon (http://www.centreon.com/) | ||
| # | ||
| # Centreon is a full-fledged industry-strength solution that meets | ||
| # the needs in IT infrastructure and application monitoring for | ||
| # service performance. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
|
|
||
| package cloud::azure::network::virtualhub::mode::discovery; | ||
|
|
||
| use base qw(cloud::azure::common::discovery); | ||
|
|
||
| use strict; | ||
| use warnings; | ||
|
|
||
| sub check_options { | ||
| my ($self, %options) = @_; | ||
| $self->SUPER::check_options(%options); | ||
|
|
||
| $self->{namespace} = 'Microsoft.Network'; | ||
| $self->{type} = 'virtualHubs'; | ||
| } | ||
|
|
||
| 1; | ||
|
|
||
| __END__ | ||
|
|
||
| =head1 MODE | ||
|
|
||
| Virtual Hub discovery. | ||
|
|
||
| =over 8 | ||
|
|
||
| =item B<--resource-group> | ||
|
|
||
| Specify resource group. | ||
|
|
||
| =item B<--location> | ||
|
|
||
| Specify location. | ||
|
|
||
| =item B<--prettify> | ||
|
|
||
| Prettify JSON output. | ||
|
|
||
| =back | ||
|
|
||
| =cut |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| # | ||
| # Copyright 2024 Centreon (http://www.centreon.com/) | ||
| # | ||
| # Centreon is a full-fledged industry-strength solution that meets | ||
| # the needs in IT infrastructure and application monitoring for | ||
| # service performance. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
|
|
||
| package cloud::azure::network::virtualhub::mode::health; | ||
|
|
||
| use base qw(cloud::azure::management::monitor::mode::health); | ||
|
|
||
| use strict; | ||
| use warnings; | ||
|
|
||
| sub check_options { | ||
| my ($self, %options) = @_; | ||
| $self->SUPER::check_options(%options); | ||
|
|
||
| $self->{az_resource_namespace} = 'Microsoft.Network'; | ||
| $self->{az_resource_type} = 'virtualHubs'; | ||
| } | ||
|
|
||
| 1; | ||
|
|
||
| __END__ | ||
|
|
||
| =head1 MODE | ||
|
|
||
| Check Virtual Hub health status. | ||
|
|
||
| =over 8 | ||
|
|
||
| =item B<--resource> | ||
|
|
||
| Set resource name or ID (required). | ||
|
|
||
| =item B<--resource-group> | ||
|
|
||
| Set resource group (required if resource's name is used). | ||
|
|
||
| =item B<--warning-status> | ||
|
|
||
| Define the conditions to match for the status to be WARNING (default: ''). | ||
| You can use the following variables: C<%{status}>, C<%{summary}>. | ||
|
|
||
| =item B<--critical-status> | ||
|
|
||
| Define the conditions to match for the status to be CRITICAL (default: C<'%{status} =~ /^Unavailable$/'>). | ||
| You can use the following variables: C<%{status}>, C<%{summary}>. | ||
|
|
||
| =item B<--unknown-status> | ||
|
|
||
| Define the conditions to match for the status to be UNKNOWN (default: C<'%{status} =~ /^Unknown$/'>). | ||
| You can use the following variables: C<%{status}>, C<%{summary}>. | ||
|
|
||
| =item B<--ok-status> | ||
|
|
||
| Define the conditions to match for the status to be OK (default: C<'%{status} =~ /^Available$/''>). | ||
| You can use the following variables: C<%{status}>, C<%{summary}>. | ||
|
|
||
| =back | ||
|
|
||
| =cut |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
azure_list_resource_metrics_set_cmd places $options{resource} directly into a shell command string (--resource '$options{resource}'), enabling command/argument injection if resource is untrusted. Use argument arrays or sanitize/encode the value.
Details
✨ AI Reasoning
A new function returns an Azure CLI command string with the --resource argument directly interpolated from $options{resource} into the command string. If $options{resource} can be controlled by an external user, this direct interpolation into a shell-executed command permits injection of additional CLI options or shell metacharacters. The risk arises where the assembled command is passed to the system execution routine without safe argument separation or sanitization.
🔧 How do I fix it?
Use parameterized queries with placeholders, array-based command execution (no shell interpretation), or properly escaped arguments using vetted libraries. Avoid dynamic queries/commands built with user input concatenation.
Reply
@AikidoSec feedback: [FEEDBACK]to get better review comments in the future.Reply
@AikidoSec ignore: [REASON]to ignore this issue.More info