mirror of
https://codeberg.org/scip/Config-General.git
synced 2026-11-22 15:48:59 +01:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dcfbc5b8a7 | |||
| 1b801a3b63 | |||
|
|
d0e7c67d1b | ||
|
|
9a3e72d7d1 | ||
| d35ece0279 | |||
| d6dae42209 | |||
|
|
14e55606ac |
18
.woodpecker/build.yaml
Normal file
18
.woodpecker/build.yaml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- image: perl:5.22.4-stretch
|
||||||
|
- image: perl:5.36.0-slim-bullseye
|
||||||
|
- image: perl:5.38.0-slim-bookworm
|
||||||
|
- image: perl:5.40.0-slim-bookworm
|
||||||
|
- image: perl:5.42.0-slim-bookworm
|
||||||
|
- image: perl:5.43.5-slim-bookworm
|
||||||
|
|
||||||
|
steps:
|
||||||
|
test:
|
||||||
|
when:
|
||||||
|
event: [push]
|
||||||
|
image: ${image}
|
||||||
|
commands:
|
||||||
|
- perl Makefile.PL
|
||||||
|
- make
|
||||||
|
- make test
|
||||||
54
.woodpecker/release.sh
Executable file
54
.woodpecker/release.sh
Executable file
@@ -0,0 +1,54 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# This is my own simple codeberg generic releaser. It takes to
|
||||||
|
# binaries to be uploaded as arguments and takes every other args from
|
||||||
|
# env. Works on tags or normal commits (push), tags must start with v.
|
||||||
|
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
die() {
|
||||||
|
echo $*
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if test -z "$DEPLOY_TOKEN"; then
|
||||||
|
die "token DEPLOY_TOKEN not set"
|
||||||
|
fi
|
||||||
|
|
||||||
|
git fetch --all
|
||||||
|
|
||||||
|
# determine current tag or commit hash
|
||||||
|
version="$CI_COMMIT_TAG"
|
||||||
|
previous=""
|
||||||
|
log=""
|
||||||
|
if test -z "$version"; then
|
||||||
|
version="${CI_COMMIT_SHA:0:6}"
|
||||||
|
log=$(git log -1 --oneline)
|
||||||
|
else
|
||||||
|
previous=$(git tag -l | grep -E "^v" | tac | grep -A1 "$version" | tail -1)
|
||||||
|
log=$(git log -1 --oneline "${previous}..${version}" | sed 's|^|- |g')
|
||||||
|
fi
|
||||||
|
|
||||||
|
# release body
|
||||||
|
printf "# Changes\n\n %s\n" "$log" > body.txt
|
||||||
|
|
||||||
|
# create the release
|
||||||
|
https --ignore-stdin --check-status -b -A bearer -a "$DEPLOY_TOKEN" POST \
|
||||||
|
"https://codeberg.org/api/v1/repos/${CI_REPO_OWNER}/${CI_REPO_NAME}/releases" \
|
||||||
|
tag_name="$version" name="Release $version" body=@body.txt > release.json
|
||||||
|
|
||||||
|
# we need the id to upload files
|
||||||
|
ID=$(jq -r .id < release.json)
|
||||||
|
|
||||||
|
if test -z "$ID"; then
|
||||||
|
cat release.json
|
||||||
|
die "failed to create release"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# actually upload
|
||||||
|
for file in "$@"; do
|
||||||
|
https --ignore-stdin --check-status -A bearer -a "$DEPLOY_TOKEN" -f POST \
|
||||||
|
"https://codeberg.org/api/v1/repos/${CI_REPO_OWNER}/${CI_REPO_NAME}/releases/$ID/assets" \
|
||||||
|
"name=${file}" "attachment@${file}"
|
||||||
|
done
|
||||||
23
.woodpecker/release.yaml
Normal file
23
.woodpecker/release.yaml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# build release
|
||||||
|
|
||||||
|
steps:
|
||||||
|
compile:
|
||||||
|
when:
|
||||||
|
event: [tag]
|
||||||
|
image: perl:5.43.5-slim-bookworm
|
||||||
|
commands:
|
||||||
|
- perl Makefile.PL
|
||||||
|
- make
|
||||||
|
- make dist
|
||||||
|
|
||||||
|
release:
|
||||||
|
image: alpine:latest
|
||||||
|
when:
|
||||||
|
event: [tag]
|
||||||
|
environment:
|
||||||
|
DEPLOY_TOKEN:
|
||||||
|
from_secret: DEPLOY_TOKEN
|
||||||
|
commands:
|
||||||
|
- apk update
|
||||||
|
- apk add --no-cache bash httpie jq git
|
||||||
|
- .woodpecker/release.sh Config-General-$CI_COMMIT_TAG.tar.gz
|
||||||
14
Changelog
14
Changelog
@@ -1,13 +1,19 @@
|
|||||||
2.67 - fix github.com/TLINDEN/Config-General/issues/5:
|
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:
|
||||||
fixing tests (add missing file to dist tarball) contributed
|
fixing tests (add missing file to dist tarball) contributed
|
||||||
by @paulwalrath.
|
by @paulwalrath.
|
||||||
- created gitignore file.
|
- created gitignore file.
|
||||||
|
|
||||||
2.66 - fix github.com/TLINDEN/Config-General/issues/1:
|
2.66 - fix codeberg.org/scip/Config-General/issues/1:
|
||||||
add support to quote values containing whitespace using the
|
add support to quote values containing whitespace using the
|
||||||
new flag -AlwaysQuoteOutput.
|
new flag -AlwaysQuoteOutput.
|
||||||
|
|
||||||
- apply patch by @haarg github.com/TLINDEN/Config-General/pull/2:
|
- apply patch by @haarg codeberg.org/scip/Config-General/pull/2:
|
||||||
fix exporter setup, use "our" where appropriate.
|
fix exporter setup, use "our" where appropriate.
|
||||||
|
|
||||||
2.65 - fix rt.cpan.org#132893: clarified license, now licensed
|
2.65 - fix rt.cpan.org#132893: clarified license, now licensed
|
||||||
@@ -25,7 +31,7 @@
|
|||||||
- the Catalyst folks who hosted the source of this module
|
- the Catalyst folks who hosted the source of this module
|
||||||
closed or moved the repository, I have not been informed and
|
closed or moved the repository, I have not been informed and
|
||||||
have therefore lost all history of the module. So I moved
|
have therefore lost all history of the module. So I moved
|
||||||
to github (https://github.com/TLINDEN/Config-General).
|
to github (https://codeberg.org/scip/Config-General).
|
||||||
Thanks for nothing, Catalyst.
|
Thanks for nothing, Catalyst.
|
||||||
|
|
||||||
2.63 - fix for rt.cpan.org#116340: do only consider a backslash
|
2.63 - fix for rt.cpan.org#116340: do only consider a backslash
|
||||||
|
|||||||
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
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
"release_status" : "stable",
|
"release_status" : "stable",
|
||||||
"resources" : {
|
"resources" : {
|
||||||
"repository" : {
|
"repository" : {
|
||||||
"url" : "https://github.com/TLINDEN/Config-General"
|
"url" : "https://codeberg.org/scip/Config-General"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"version" : "2.67"
|
"version" : "2.67"
|
||||||
|
|||||||
2
META.yml
2
META.yml
@@ -23,5 +23,5 @@ requires:
|
|||||||
FileHandle: 0
|
FileHandle: 0
|
||||||
IO::File: 0
|
IO::File: 0
|
||||||
resources:
|
resources:
|
||||||
repository: https://github.com/TLINDEN/Config-General
|
repository: https://codeberg.org/scip/Config-General
|
||||||
version: 2.65
|
version: 2.65
|
||||||
|
|||||||
@@ -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.
|
||||||
#
|
#
|
||||||
@@ -22,7 +22,7 @@ WriteMakefile(
|
|||||||
},
|
},
|
||||||
'META_MERGE' => {
|
'META_MERGE' => {
|
||||||
resources => {
|
resources => {
|
||||||
repository => 'https://github.com/TLINDEN/Config-General'
|
repository => 'https://codeberg.org/scip/Config-General'
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
($ExtUtils::MakeMaker::VERSION ge '6.31'?
|
($ExtUtils::MakeMaker::VERSION ge '6.31'?
|
||||||
|
|||||||
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