Skip to content
Open
Show file tree
Hide file tree
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 Mar 20, 2025
9274e64
fix(ci): add missing image + fix path for tests on noble (#5516)
omercier Mar 21, 2025
e74825a
Merge branch 'centreon:develop' into develop
garnier-quentin Apr 9, 2025
75a686f
Merge branch 'centreon:develop' into develop
garnier-quentin Apr 23, 2025
06d9cca
Merge branch 'centreon:develop' into develop
garnier-quentin Apr 29, 2025
a655ae5
Merge branch 'centreon:develop' into develop
garnier-quentin May 13, 2025
0e2a2c2
Merge branch 'centreon:develop' into develop
garnier-quentin May 14, 2025
868a37b
Merge branch 'centreon:develop' into develop
garnier-quentin Jun 4, 2025
6fd626e
Merge branch 'centreon:develop' into develop
garnier-quentin Jun 12, 2025
cf2d401
Merge branch 'centreon:develop' into develop
garnier-quentin Jul 17, 2025
7930cbe
Merge branch 'centreon:develop' into develop
garnier-quentin Sep 16, 2025
7ef7c1c
Merge branch 'centreon:develop' into develop
garnier-quentin Sep 25, 2025
adbb960
Merge branch 'centreon:develop' into develop
garnier-quentin Dec 11, 2025
4b45367
Merge branch 'centreon:develop' into develop
garnier-quentin Dec 22, 2025
dc85ae4
Merge branch 'centreon:develop' into develop
garnier-quentin Jan 7, 2026
4243e13
Merge branch 'centreon:develop' into develop
garnier-quentin Feb 10, 2026
b6020da
Merge branch 'centreon:develop' into develop
garnier-quentin Mar 16, 2026
339e322
Merge branch 'centreon:develop' into develop
garnier-quentin Mar 26, 2026
55acdb5
wip
garnier-quentin Mar 26, 2026
eeab9a7
wip
garnier-quentin Apr 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"dependencies": [
]
}
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/"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"dependencies": [
]
}
179 changes: 179 additions & 0 deletions src/apps/atlassian/statuspage/custom/json.pm
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
137 changes: 137 additions & 0 deletions src/apps/atlassian/statuspage/mode/components.pm
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 '' &&
Copy link
Copy Markdown

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

Copy link
Copy Markdown
Contributor Author

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.

$_->{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
Loading