Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config option use taint #181

Merged
merged 7 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions README.pod
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ This extension contributes the following settings:

=item * C<sudoUser>: optional, if set run debug process with sudo -u \<sudoUser\>.

=item * C<useTaintForDebug>: optional, if true run debug process with -T (taint mode).

=item * C<containerCmd>: If set debugger runs inside a container. Options are: 'docker', 'docker-compose', 'podman', 'kubectl'

=item * C<containerArgs>: arguments for containerCmd. Varies depending on containerCmd.
Expand Down
1 change: 1 addition & 0 deletions clients/vscode/perl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ This extension contributes the following settings:
* `cwd`: optional, change working directory before launching the debuggee
* `reloadModules`: if true, automatically reload changed Perl modules while debugging
* `sudoUser`: optional, if set run debug process with sudo -u \<sudoUser\>.
* `useTaintForDebug`: optional, if true run debug process with -T (taint mode).
* `containerCmd`: If set debugger runs inside a container. Options are: 'docker', 'docker-compose', 'podman', 'kubectl'
* `containerArgs`: arguments for containerCmd. Varies depending on containerCmd.
* `containerMode`: To start a new container, set to 'run', to debug inside an existing container set to 'exec'. Note: kubectl only supports 'exec'
Expand Down
5 changes: 5 additions & 0 deletions clients/vscode/perl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@
"description": "optional, if set run debug process with sudo -u <sudoUser>.",
"default": null
},
"useTaintForDebug": {
"type": "boolean",
"description": "optional, if set run debug process in taint mode.",
"default": false
},
"pathMap": {
"type": "array",
"default": null,
Expand Down
2 changes: 2 additions & 0 deletions lib/Perl/LanguageServer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,8 @@ This extension contributes the following settings:

=item * C<sudoUser>: optional, if set run debug process with sudo -u \<sudoUser\>.

=item * C<useTaintForDebug>: optional, if true run debug process with -T (taint mode).

=item * C<containerCmd>: If set debugger runs inside a container. Options are: 'docker', 'docker-compose', 'podman', 'kubectl'

=item * C<containerArgs>: arguments for containerCmd. Varies depending on containerCmd.
Expand Down
6 changes: 6 additions & 0 deletions lib/Perl/LanguageServer/DebuggerInterface.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1702,6 +1702,12 @@ sub init
my $remote ;
my $port ;
($remote, $port) = split /:/, $ENV{PLSDI_REMOTE} ;
if ($remote =~ m/^([0-9.]+)$/) {
$remote = $1; # untaint
}
if ($port =~ m/^(\d+)$/) {
$port = $1; # untaint
}

$socket = IO::Socket::INET->new(PeerAddr => $remote,
PeerPort => $port,
Expand Down
11 changes: 11 additions & 0 deletions lib/Perl/LanguageServer/DebuggerProcess.pm
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ has 'sudo_user' =>
is => 'ro',
) ;

has 'use_taint_for_debug' =>
(
isa => 'Bool',
is => 'rw'
) ;

has 'path_map' =>
(
isa => 'Maybe[ArrayRef]',
Expand Down Expand Up @@ -106,6 +112,7 @@ sub BUILDARGS
$args -> {stop_on_entry} = delete $args -> {stopOnEntry}?1:0 ;
$args -> {session_id} = delete $args -> {__sessionId} || $session_cnt ;
$args -> {sudo_user} = delete $args -> {sudoUser} ;
$args -> {use_taint_for_debug} = delete $args -> {useTaintForDebug} ;
my $map = delete $args -> {pathMap} ;
if ($map)
{
Expand Down Expand Up @@ -228,6 +235,10 @@ sub launch
push @sudoargs, "PERL5DB=$ENV{PERL5DB}" ;
push @sudoargs, "PLSDI_SESSION=$ENV{PLSDI_SESSION}" ;
}
if ($self->use_taint_for_debug)
{
push @inc, "-T" ;
}

if (ref $self -> args) # ref is array
{
Expand Down