mirror of
https://codeberg.org/scip/Config-General.git
synced 2026-11-22 23:58:59 +01:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dcfbc5b8a7 | |||
| 1b801a3b63 | |||
|
|
d0e7c67d1b | ||
|
|
9a3e72d7d1 |
@@ -3,7 +3,7 @@
|
|||||||
steps:
|
steps:
|
||||||
compile:
|
compile:
|
||||||
when:
|
when:
|
||||||
event: [tag,manual]
|
event: [tag]
|
||||||
image: perl:5.43.5-slim-bookworm
|
image: perl:5.43.5-slim-bookworm
|
||||||
commands:
|
commands:
|
||||||
- perl Makefile.PL
|
- perl Makefile.PL
|
||||||
@@ -13,7 +13,7 @@ steps:
|
|||||||
release:
|
release:
|
||||||
image: alpine:latest
|
image: alpine:latest
|
||||||
when:
|
when:
|
||||||
event: [tag,manual]
|
event: [tag]
|
||||||
environment:
|
environment:
|
||||||
DEPLOY_TOKEN:
|
DEPLOY_TOKEN:
|
||||||
from_secret: DEPLOY_TOKEN
|
from_secret: DEPLOY_TOKEN
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
|
2.69 - fix Changelog
|
||||||
|
|
||||||
|
2.68 - fixes fix codeberg.org/scip/Config-General/issues/10:
|
||||||
|
and closes CVE-2026-129820 + CVE-2026-129821:
|
||||||
|
validate incoming config hashes, forbid comment, here-doc and include markers
|
||||||
|
|
||||||
2.67 - fix codeberg.org/scip/Config-General/issues/5:
|
2.67 - fix codeberg.org/scip/Config-General/issues/5:
|
||||||
fixing tests (add missing file to dist tarball) contributed
|
fixing tests (add missing file to dist tarball) contributed
|
||||||
by @paulwalrath.
|
by @paulwalrath.
|
||||||
|
|||||||
77
General.pm
77
General.pm
@@ -5,7 +5,7 @@
|
|||||||
# config values from a given file and
|
# config values from a given file and
|
||||||
# return it as hash structure
|
# return it as hash structure
|
||||||
#
|
#
|
||||||
# Copyright (c) 2000-2025 Thomas Linden <tlinden |AT| cpan.org>.
|
# Copyright (c) 2000-2026 Thomas Linden <tlinden |AT| cpan.org>.
|
||||||
# All Rights Reserved. Std. disclaimer applies.
|
# All Rights Reserved. Std. disclaimer applies.
|
||||||
# Licensed under the Artistic License 2.0.
|
# Licensed under the Artistic License 2.0.
|
||||||
#
|
#
|
||||||
@@ -20,7 +20,7 @@ use IO::File;
|
|||||||
use FileHandle;
|
use FileHandle;
|
||||||
use File::Spec::Functions qw(splitpath file_name_is_absolute catfile catpath);
|
use File::Spec::Functions qw(splitpath file_name_is_absolute catfile catpath);
|
||||||
use File::Glob qw/:glob/;
|
use File::Glob qw/:glob/;
|
||||||
|
use Data::Dumper;
|
||||||
|
|
||||||
# on debian with perl > 5.8.4 croak() doesn't work anymore without this.
|
# on debian with perl > 5.8.4 croak() doesn't work anymore without this.
|
||||||
# There is some require statement which dies 'cause it can't find Carp::Heavy,
|
# There is some require statement which dies 'cause it can't find Carp::Heavy,
|
||||||
@@ -32,7 +32,7 @@ use Carp::Heavy;
|
|||||||
use Carp;
|
use Carp;
|
||||||
use Exporter;
|
use Exporter;
|
||||||
|
|
||||||
$Config::General::VERSION = "2.67";
|
$Config::General::VERSION = "2.69";
|
||||||
|
|
||||||
use base qw(Exporter);
|
use base qw(Exporter);
|
||||||
our @EXPORT_OK = qw(ParseConfig SaveConfig SaveConfigString);
|
our @EXPORT_OK = qw(ParseConfig SaveConfig SaveConfigString);
|
||||||
@@ -286,6 +286,10 @@ sub _prepare {
|
|||||||
$self->{ConfigFile} = delete $conf{-file};
|
$self->{ConfigFile} = delete $conf{-file};
|
||||||
}
|
}
|
||||||
if (exists $conf{-hash}) {
|
if (exists $conf{-hash}) {
|
||||||
|
if (! $self->_validate_input_hash($conf{-hash})) {
|
||||||
|
croak "Config::General: supplied -hash hash contains invalid keys or values!\n";
|
||||||
|
}
|
||||||
|
|
||||||
$self->{ConfigHash} = delete $conf{-hash};
|
$self->{ConfigHash} = delete $conf{-hash};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,6 +298,10 @@ sub _prepare {
|
|||||||
$self->{ConfigFile} = delete $conf{-ConfigFile};
|
$self->{ConfigFile} = delete $conf{-ConfigFile};
|
||||||
}
|
}
|
||||||
if (exists $conf{-ConfigHash}) {
|
if (exists $conf{-ConfigHash}) {
|
||||||
|
if (! $self->_validate_input_hash($conf{-ConfigHash})) {
|
||||||
|
croak "Config::General: supplied -ConfigHash hash contains invalid keys or values!\n";
|
||||||
|
}
|
||||||
|
|
||||||
$self->{ConfigHash} = delete $conf{-ConfigHash};
|
$self->{ConfigHash} = delete $conf{-ConfigHash};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -340,6 +348,10 @@ sub _prepare {
|
|||||||
if (exists $conf{-DefaultConfig}) {
|
if (exists $conf{-DefaultConfig}) {
|
||||||
if ($conf{-DefaultConfig} && ref($conf{-DefaultConfig}) eq 'HASH') {
|
if ($conf{-DefaultConfig} && ref($conf{-DefaultConfig}) eq 'HASH') {
|
||||||
# copy the hashref so that it is not being modified by subsequent calls, fixes bug#142095
|
# copy the hashref so that it is not being modified by subsequent calls, fixes bug#142095
|
||||||
|
if (! $self->_validate_input_hash($conf{-DefaultConfig})) {
|
||||||
|
croak "Config::General: supplied -DefaultConfig hash contains invalid keys or values!\n";
|
||||||
|
}
|
||||||
|
|
||||||
$self->{DefaultConfig} = $self->_copy($conf{-DefaultConfig});
|
$self->{DefaultConfig} = $self->_copy($conf{-DefaultConfig});
|
||||||
}
|
}
|
||||||
elsif ($conf{-DefaultConfig} && ref($conf{-DefaultConfig}) eq q()) {
|
elsif ($conf{-DefaultConfig} && ref($conf{-DefaultConfig}) eq q()) {
|
||||||
@@ -1494,6 +1506,61 @@ sub _hashref {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub _validate_input_hash {
|
||||||
|
#
|
||||||
|
# Checks if a given input hash contains invalid keys or values.
|
||||||
|
# Fixes https://codeberg.org/scip/Config-General/issues/9.
|
||||||
|
#
|
||||||
|
my($this, $hash) = @_;
|
||||||
|
|
||||||
|
if (ref($hash) eq '') {
|
||||||
|
return $this->_validate_input_hash_value($hash);
|
||||||
|
}
|
||||||
|
elsif (ref($hash) eq 'ARRAY') {
|
||||||
|
foreach my $sub (@{$hash}) {
|
||||||
|
return $this->_validate_input_hash($sub);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach my $key (keys %{$hash}) {
|
||||||
|
if (! $this->_validate_input_hash_value($key)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ref($hash->{$key}) eq 'ARRAY') {
|
||||||
|
foreach my $sub (@{$hash->{$key}}) {
|
||||||
|
if (! $this->_validate_input_hash($sub)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elsif(ref($hash->{$key}) eq 'HASH') {
|
||||||
|
if (! $this->_validate_input_hash($hash->{$key})) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (! $this->_validate_input_hash_value($hash->{$key})) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub _validate_input_hash_value {
|
||||||
|
#
|
||||||
|
# Checks a given key or value against a deny regex
|
||||||
|
my ($this, $value) = @_;
|
||||||
|
|
||||||
|
if ($value =~ /(<<|>>|\*\/|\/\*|#)/) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Procedural interface
|
# Procedural interface
|
||||||
@@ -2859,7 +2926,7 @@ I recommend you to read the following documents, which are supplied with Perl:
|
|||||||
|
|
||||||
=head1 LICENSE AND COPYRIGHT
|
=head1 LICENSE AND COPYRIGHT
|
||||||
|
|
||||||
Copyright (c) 2000-2025 Thomas Linden
|
Copyright (c) 2000-2026 Thomas Linden
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the same terms of the Artistic License 2.0.
|
modify it under the same terms of the Artistic License 2.0.
|
||||||
@@ -2888,7 +2955,7 @@ Thomas Linden <tlinden |AT| cpan.org>
|
|||||||
|
|
||||||
=head1 VERSION
|
=head1 VERSION
|
||||||
|
|
||||||
2.67
|
2.69
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# Makefile.PL - build file for Config::General
|
# Makefile.PL - build file for Config::General
|
||||||
#
|
#
|
||||||
# Copyright (c) 2000-2022 Thomas Linden <tom@daemon.de>.
|
# Copyright (c) 2000-2026 Thomas Linden <tom@daemon.de>.
|
||||||
# All Rights Reserved. Std. disclaimer applies.
|
# All Rights Reserved. Std. disclaimer applies.
|
||||||
# Licensed under the Artistic License 2.0.
|
# Licensed under the Artistic License 2.0.
|
||||||
#
|
#
|
||||||
|
|||||||
65
t/run.t
65
t/run.t
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
|
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
use Test::More tests => 79;
|
use Test::More tests => 93;
|
||||||
#use Test::More qw(no_plan);
|
#use Test::More qw(no_plan);
|
||||||
|
|
||||||
# ahem, we deliver the test code with a local copy of
|
# ahem, we deliver the test code with a local copy of
|
||||||
@@ -801,3 +801,66 @@ my $conf59 = Config::General->new(
|
|||||||
-AlwaysQuoteOutput => 1);
|
-AlwaysQuoteOutput => 1);
|
||||||
my $got59 = $conf59->save_string();
|
my $got59 = $conf59->save_string();
|
||||||
is_deeply \$expected59, \$got59, "quotes";
|
is_deeply \$expected59, \$got59, "quotes";
|
||||||
|
|
||||||
|
|
||||||
|
# test for CVE-2026-129820 and CVE-2026-129821 fixes
|
||||||
|
my $cvedefaults = [
|
||||||
|
{
|
||||||
|
"*/ foo" => 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"foo */" => 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"foo <<EOF foo" => 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"<<include nix>>" => 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"*/ foo" => "hans",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"foo # 1" => "nix",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"foo" => "*/ hier",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"foo" => "hier */",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"foo" => "<<EOF hier",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"foo" => "<<include hier>>",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"users" => {
|
||||||
|
"hans" => "*/ maddock",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"users" => {
|
||||||
|
"hans" => "maddock /*",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"users" => {
|
||||||
|
"hans" => "<<EOF maddock",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"list" => [
|
||||||
|
"ok",
|
||||||
|
"*/ foo",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
];
|
||||||
|
foreach my $default (@{$cvedefaults}) {
|
||||||
|
eval {
|
||||||
|
my $conf60 = Config::General->new(-ConfigHash => $default) or die "$@";
|
||||||
|
};
|
||||||
|
|
||||||
|
ok($@, "cve check failed: " . Dumper($default));
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user