-
Notifications
You must be signed in to change notification settings - Fork 302
CTOR-2244 [apps::atlassian::statuspage] - new plugin #6073
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
Open
garnier-quentin
wants to merge
20
commits into
centreon:develop
Choose a base branch
from
garnier-quentin:CTOR-2244-atlassian-statuspage
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
4909454
fix(ci): add missing image + fix path for tests on noble
omercier 9274e64
fix(ci): add missing image + fix path for tests on noble (#5516)
omercier e74825a
Merge branch 'centreon:develop' into develop
garnier-quentin 75a686f
Merge branch 'centreon:develop' into develop
garnier-quentin 06d9cca
Merge branch 'centreon:develop' into develop
garnier-quentin a655ae5
Merge branch 'centreon:develop' into develop
garnier-quentin 0e2a2c2
Merge branch 'centreon:develop' into develop
garnier-quentin 868a37b
Merge branch 'centreon:develop' into develop
garnier-quentin 6fd626e
Merge branch 'centreon:develop' into develop
garnier-quentin cf2d401
Merge branch 'centreon:develop' into develop
garnier-quentin 7930cbe
Merge branch 'centreon:develop' into develop
garnier-quentin 7ef7c1c
Merge branch 'centreon:develop' into develop
garnier-quentin adbb960
Merge branch 'centreon:develop' into develop
garnier-quentin 4b45367
Merge branch 'centreon:develop' into develop
garnier-quentin dc85ae4
Merge branch 'centreon:develop' into develop
garnier-quentin 4243e13
Merge branch 'centreon:develop' into develop
garnier-quentin b6020da
Merge branch 'centreon:develop' into develop
garnier-quentin 339e322
Merge branch 'centreon:develop' into develop
garnier-quentin 55acdb5
wip
garnier-quentin eeab9a7
wip
garnier-quentin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
packaging/centreon-plugin-Applications-Atlassian-Statuspage/deb.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "dependencies": [ | ||
| ] | ||
| } |
9 changes: 9 additions & 0 deletions
9
packaging/centreon-plugin-Applications-Atlassian-Statuspage/pkg.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "pkg_name": "centreon-plugin-Applications-Atlassian-Statuspage", | ||
| "pkg_summary": "Centreon Plugin", | ||
| "plugin_name": "centreon_atlassian_statuspage.pl", | ||
| "files": [ | ||
| "centreon/plugins/script_custom.pm", | ||
| "apps/atlassian/statuspage/" | ||
| ] | ||
| } |
4 changes: 4 additions & 0 deletions
4
packaging/centreon-plugin-Applications-Atlassian-Statuspage/rpm.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "dependencies": [ | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,179 @@ | ||
| # | ||
| # Copyright 2026-Present 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 apps::atlassian::statuspage::custom::json; | ||
|
|
||
| use strict; | ||
| use warnings; | ||
| use centreon::plugins::http; | ||
| use JSON::XS; | ||
| use Digest::MD5 qw(md5_hex); | ||
|
|
||
| sub new { | ||
| my ($class, %options) = @_; | ||
| my $self = {}; | ||
| bless $self, $class; | ||
|
|
||
| if (!defined($options{output})) { | ||
| print "Class Custom: Need to specify 'output' argument.\n"; | ||
| exit 3; | ||
| } | ||
| if (!defined($options{options})) { | ||
| $options{output}->add_option_msg(short_msg => "Class Custom: Need to specify 'options' argument."); | ||
| $options{output}->option_exit(); | ||
| } | ||
|
|
||
| if (!defined($options{noptions})) { | ||
| $options{options}->add_options(arguments => { | ||
| 'hostname:s' => { name => 'hostname' }, | ||
| 'port:s' => { name => 'port' }, | ||
| 'proto:s' => { name => 'proto' }, | ||
| 'timeout:s' => { name => 'timeout' }, | ||
| 'api-endpoint:s' => { name => 'api_endpoint' }, | ||
| 'unknown-http-status:s' => { name => 'unknown_http_status' }, | ||
| 'warning-http-status:s' => { name => 'warning_http_status' }, | ||
| 'critical-http-status:s' => { name => 'critical_http_status' } | ||
| }); | ||
| } | ||
| $options{options}->add_help(package => __PACKAGE__, sections => 'API OPTIONS', once => 1); | ||
|
|
||
| $self->{output} = $options{output}; | ||
| $self->{http} = centreon::plugins::http->new(%options, default_backend => 'curl'); | ||
|
|
||
| return $self; | ||
| } | ||
|
|
||
| sub set_options { | ||
| my ($self, %options) = @_; | ||
|
|
||
| $self->{option_results} = $options{option_results}; | ||
| } | ||
|
|
||
| sub set_defaults {} | ||
|
|
||
| sub check_options { | ||
| my ($self, %options) = @_; | ||
|
|
||
| $self->{option_results}->{hostname} = (defined($self->{option_results}->{hostname})) ? $self->{option_results}->{hostname} : ''; | ||
| $self->{option_results}->{port} = (defined($self->{option_results}->{port})) ? $self->{option_results}->{port} : 443; | ||
| $self->{option_results}->{proto} = (defined($self->{option_results}->{proto})) ? $self->{option_results}->{proto} : 'https'; | ||
| $self->{option_results}->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 30; | ||
| $self->{option_results}->{api_endpoint} = (defined($self->{option_results}->{api_endpoint})) ? $self->{option_results}->{api_endpoint} : '/api/v2/'; | ||
| $self->{unknown_http_status} = (defined($self->{option_results}->{unknown_http_status})) ? $self->{option_results}->{unknown_http_status} : '%{http_code} < 200 or %{http_code} >= 300'; | ||
| $self->{warning_http_status} = (defined($self->{option_results}->{warning_http_status})) ? $self->{option_results}->{warning_http_status} : ''; | ||
| $self->{critical_http_status} = (defined($self->{option_results}->{critical_http_status})) ? $self->{option_results}->{critical_http_status} : ''; | ||
|
|
||
| if ($self->{option_results}->{hostname} eq '') { | ||
| $self->{output}->add_option_msg(short_msg => 'Need to specify --hostname option.'); | ||
| $self->{output}->option_exit(); | ||
| } | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| sub settings { | ||
| my ($self, %options) = @_; | ||
|
|
||
| return if (defined($self->{settings_done})); | ||
| $self->{http}->set_options(%{$self->{option_results}}); | ||
| $self->{http}->add_header(key => 'Accept', value => 'application/json'); | ||
| $self->{settings_done} = 1; | ||
| } | ||
|
|
||
| sub get_connection_info { | ||
| my ($self, %options) = @_; | ||
|
|
||
| return $self->{option_results}->{hostname} . ':' . $self->{option_results}->{port}; | ||
| } | ||
|
|
||
| sub request_api { | ||
| my ($self, %options) = @_; | ||
|
|
||
| $self->settings(); | ||
| my ($content) = $self->{http}->request( | ||
| url_path => $self->{option_results}->{api_endpoint} . $options{request}, | ||
| unknown_status => $self->{unknown_http_status}, | ||
| warning_status => $self->{warning_http_status}, | ||
| critical_status => $self->{critical_http_status} | ||
| ); | ||
|
|
||
| if (!defined($content) || $content eq '') { | ||
| $self->{output}->add_option_msg(short_msg => "API returns empty content [code: '" . $self->{http}->get_code() . "'] [message: '" . $self->{http}->get_message() . "']"); | ||
| $self->{output}->option_exit(); | ||
| } | ||
|
|
||
| my $decoded; | ||
| eval { | ||
| $decoded = JSON::XS->new->allow_nonref(1)->utf8->decode($content); | ||
| }; | ||
| if ($@) { | ||
| $self->{output}->add_option_msg(short_msg => "Cannot decode response (add --debug option to display returned content)"); | ||
| $self->{output}->option_exit(); | ||
| } | ||
|
|
||
| return $decoded; | ||
| } | ||
|
|
||
| sub get_components { | ||
| my ($self, %options) = @_; | ||
|
|
||
| return $self->request_api(request => 'components.json'); | ||
| } | ||
|
|
||
| 1; | ||
|
|
||
| __END__ | ||
|
|
||
| =head1 NAME | ||
|
|
||
| Public JSON API | ||
|
|
||
| =head1 API OPTIONS | ||
|
|
||
| Public JSON API | ||
|
|
||
| =over 8 | ||
|
|
||
| =item B<--hostname> | ||
|
|
||
| Set hostname. | ||
|
|
||
| =item B<--port> | ||
|
|
||
| Port used (default: 443) | ||
|
|
||
| =item B<--proto> | ||
|
|
||
| Specify https if needed (default: 'https') | ||
|
|
||
| =item B<--api-endpoint> | ||
|
|
||
| Argos API requests endpoint (default: '/api/v2/') | ||
|
|
||
| =item B<--timeout> | ||
|
|
||
| Set timeout in seconds (default: 30). | ||
|
|
||
| =back | ||
|
|
||
| =head1 DESCRIPTION | ||
|
|
||
| B<custom>. | ||
|
|
||
| =cut |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| # | ||
| # Copyright 2026-Present 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 apps::atlassian::statuspage::mode::components; | ||
|
|
||
| use base qw(centreon::plugins::templates::counter); | ||
|
|
||
| use strict; | ||
| use warnings; | ||
| use centreon::plugins::constants qw(:counters :values); | ||
| use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng); | ||
|
|
||
| sub custom_component_status_output { | ||
| my ($self, %options) = @_; | ||
|
|
||
| return sprintf( | ||
| 'status: %s', | ||
| $self->{result_values}->{status} | ||
| ); | ||
| } | ||
|
|
||
| sub prefix_component_output { | ||
| my ($self, %options) = @_; | ||
|
|
||
| return "Component '" . $options{instance_value}->{name} . "' "; | ||
| } | ||
|
|
||
| sub set_counters { | ||
| my ($self, %options) = @_; | ||
|
|
||
| $self->{maps_counters_type} = [ | ||
| { name => 'components', type => COUNTER_TYPE_INSTANCE, cb_prefix_output => 'prefix_component_output', message_multiple => 'All components are ok' } | ||
| ]; | ||
|
|
||
| $self->{maps_counters}->{components} = [ | ||
| { | ||
| label => 'status', | ||
| type => COUNTER_KIND_TEXT, | ||
| warningd_default => '%{status} =~ /degraded_performance|partial_outage/', | ||
| critical_default => '%{status} =~ /major_outage/', | ||
| set => { | ||
| key_values => [ | ||
| { name => 'status' }, { name => 'name' } | ||
| ], | ||
| closure_custom_output => $self->can('custom_component_status_output'), | ||
| closure_custom_perfdata => sub { return 0; }, | ||
| closure_custom_threshold_check => \&catalog_status_threshold_ng | ||
| } | ||
| } | ||
| ]; | ||
| } | ||
|
|
||
| sub new { | ||
| my ($class, %options) = @_; | ||
| my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); | ||
| bless $self, $class; | ||
|
|
||
| $options{options}->add_options(arguments => { | ||
| 'filter-component-id:s' => { name => 'filter_component_id' }, | ||
| 'filter-component-name:s' => { name => 'filter_component_name' } | ||
| }); | ||
|
|
||
| return $self; | ||
| } | ||
|
|
||
| sub manage_selection { | ||
| my ($self, %options) = @_; | ||
|
|
||
| my $results = $options{custom}->get_components(); | ||
|
|
||
| $self->{components} = {}; | ||
| foreach (@{$results->{components}}) { | ||
| next if (defined($self->{option_results}->{filter_component_id}) && $self->{option_results}->{filter_component_id} ne '' && | ||
| $_->{id} !~ /$self->{option_results}->{filter_component_id}/); | ||
| next if (defined($self->{option_results}->{filter_component_name}) && $self->{option_results}->{filter_component_name} ne '' && | ||
| $_->{name} !~ /$self->{option_results}->{filter_component_name}/); | ||
|
|
||
| $self->{components}->{ $_->{id} } = { | ||
| name => $_->{name}, | ||
| status => $_->{status} | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| 1; | ||
|
|
||
| __END__ | ||
|
|
||
| =head1 MODE | ||
|
|
||
| Check components. | ||
|
|
||
| =over 8 | ||
|
|
||
| =item B<--filter-component-id> | ||
|
|
||
| Filter components by ID (can be a regexp). | ||
|
|
||
| =item B<--filter-component-name> | ||
|
|
||
| Filter components by name (can be a regexp). | ||
|
|
||
| =item B<--unknown-status> | ||
|
|
||
| Define the conditions to match for the status to be UNKNOWN. | ||
| You can use the following variables: %{status}, %{name} | ||
|
|
||
| =item B<--warning-status> | ||
|
|
||
| Define the conditions to match for the status to be WARNING (default: '%{status} =~ /degraded_performance|partial_outage/'). | ||
| You can use the following variables: %{status}, %{name} | ||
|
|
||
| =item B<--critical-status> | ||
|
|
||
| Define the conditions to match for the status to be CRITICAL (default: '%{status} =~ /major_outage/'). | ||
| You can use the following variables: %{status}, %{name} | ||
|
|
||
| =back | ||
|
|
||
| =cut | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
User-supplied --filter-component-name is interpolated directly into a regex ( $_->{name} !~ /$self->{option_results}->{filter_component_name}/ ). Validate or escape the input before using it in a regex to avoid regex injection/DoS.
Details
✨ AI Reasoning
The code builds regular expressions directly from values that can be provided by users (CLI options). Direct interpolation into regex literals can allow crafted input to change matching behavior, cause runtime errors, or trigger catastrophic backtracking. The problematic expressions are used for filtering and are not sanitized or validated. This was introduced by the new component filtering logic that applies these option values directly into regex matches.
🔧 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
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.
The goal of that option is to used regexp. If we escape regexp, we cant use regexp. That alert is not very smart in our context i think.