From 7bf564ae894678de023d9dc7660e3556393434aa Mon Sep 17 00:00:00 2001 From: Jacob Bachmeyer Date: Fri, 4 Aug 2023 19:14:49 -0500 Subject: [PATCH] Convert directive interpretation and validation to method calls --- gatekeeper.pl | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/gatekeeper.pl b/gatekeeper.pl index 2e09ece..cd2851a 100755 --- a/gatekeeper.pl +++ b/gatekeeper.pl @@ -1753,9 +1753,8 @@ sub read_directive_from_string { $self->{directive} = ::read_directive_from_string($self->{directive_text}); - $self->{oplist} = interpret_directive($self->{directive}); - - validate_directive($self, $self->{oplist}); + $self->_interpret_directive; + $self->_validate_directive; } sub auth_clearsigned_message { (shift)->{directive_text} } @@ -2160,20 +2159,21 @@ sub gather_packets { =over -=item $oplist = interpret_directive ( $directive ) +=item $packet->_interpret_directive -Analyze the elements in DIRECTIVE, performing basic validation. An -exception is thrown if DIRECTIVE contains invalid element values. +Analyze the elements in the directive in PACKET, performing basic +validation. An exception is thrown if invalid element values are found. -The return value is an arrayref of command/parameter arrayrefs representing -the operations to be performed to carry out DIRECTIVE. +An arrayref of command/parameter arrayrefs representing the operations to +be performed to carry out the directive is stored in PACKET. -The values in the returned structure are untainted. +The values stored are untainted. =cut -sub Local::Packet::Directive::interpret_directive { - my $directive = shift; # presumed tainted +sub Local::Packet::Directive::_interpret_directive { + my $self = shift; + my $directive = $self->{directive}; # presumed tainted my @errors; my @trace; @@ -2356,21 +2356,21 @@ sub Local::Packet::Directive::interpret_directive { target_directory => $header{directory}; } - return \@ops; + $self->{oplist} = \@ops; } -=item validate_directive ( $packet, $oplist ) +=item $packet->_validate_directive -Validate the commands in OPLIST as applicable to PACKET. PACKET is a -packet object. OPLIST is an operation list arrayref. +Validate the commands in the operation list stored in PACKET. PACKET is a +packet object. An exception is thrown if validation fails. =cut -sub Local::Packet::Directive::validate_directive { +sub Local::Packet::Directive::_validate_directive { my $packet = shift; - my $ops = shift; + my $ops = $packet->{oplist}; my $stem = $packet->file_name_stem; my $op_header = $ops->[0][1]; -- 2.25.1