#!/usr/bin/perl
#  ALTRAN_PROLOG_BEGIN_TAG                                                    
#  This is an automatically generated prolog.                                  
#                                                                              
#  Copyright (C) Altran ACT S.A.S. 2019,2021.  All rights reserved.  
#                                                                              
#  ALTRAN_PROLOG_END_TAG                                                      
#                                                                              
# @(#)  7d4c34b 43haes/lib/perl/libcl_untaint.pm, 726, 2147A_aha726, Feb 05 2021 09:50 PM 
use Exporter;


BEGIN {
    # Remove some external variables that might not be secure.
    # These can cause security complaints from PERL. Instead
    # of accepting external values, if you need any of these,
    # you _must_ set your own.
    delete @ENV{'PATH', 'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
    # Loop through each path and individually check it, then
    # append it to PATH to remove tainting.
    for (split(":", `/usr/es/sbin/cluster/utilities/cl_get_path all`)) {
        if ($_ =~ /^([-_\w\/.]+)$/) {
                $ENV{PATH} .= "$1:" if (-d $1);
        }

    }
    chop($ENV{PATH});
}


our @ISA= qw( Exporter );

# these CAN be exported.
our @EXPORT_OK = qw( untaint );

# these are exported by default.
our @EXPORT = qw( untaint );

sub untaint {
    my $data = shift;
    if ($data =~ /([A-Za-z0-9!-}_: ,.%\t\/\s\"\'\\-]+)/){
        $data = $1;
    }
    return $data;
}