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

use taint on syntax check #172

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions Changes.pod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

=over

=item * Add setting useTaintForSyntaxCheck. If true, use taint mode for syntax check.

=item * Add debug setting for running as different user. See sudoUser setting. (#174) [wielandp]

=item * Allow to use a string for debuggee arguments. (#149, #173) [wielandp]
Expand Down
2 changes: 2 additions & 0 deletions README.pod
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ This extension contributes the following settings:

=item * C<stopOnEntry>: if true, program will stop on entry

=item * C<useTaintForSyntaxCheck>: if true, use taint mode for syntax check.

=item * C<args>: optional, array or string with arguments for perl program

=item * C<env>: optional, object with environment settings
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 @@ -114,6 +114,11 @@
"default": null,
"description": "array with paths to add to perl library path. This setting is used by the syntax checker and for the debuggee and also for the LanguageServer itself. perl.perlInc should be absolute paths."
},
"perl.useTaintForSyntaxCheck": {
"type": "boolean",
"default": false,
"description": "Use -T for syntax check."
},
"perl.fileFilter": {
"type": "array",
"default": null,
Expand Down
3 changes: 3 additions & 0 deletions lib/Perl/LanguageServer/Methods/workspace.pm
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ sub _rpcnot_didChangeConfiguration

$self -> logger ("perlinc = ", dump ( $workspace -> perlinc), "\n") ;

$workspace -> use_taint_for_syntax_check ($req -> params -> {settings}{perl}{useTaintForSyntaxCheck}) ;
$self -> logger ("use_taint_for_syntax_check = ", dump ( $workspace -> use_taint_for_syntax_check), "\n") ;

my $filter = $req -> params -> {settings}{perl}{fileFilter} ;
if ($filter)
{
Expand Down
11 changes: 8 additions & 3 deletions lib/Perl/LanguageServer/SyntaxChecker.pm
Original file line number Diff line number Diff line change
Expand Up @@ -232,23 +232,28 @@ sub background_checker
my @inc ;
@inc = map { ('-I', $_)} @$inc if ($inc) ;

$self -> logger ("start perl -c for $uri\n") if ($Perl::LanguageServer::debug1) ;
my $syntax_options = "";
if ($self -> use_taint_for_syntax_check) {
$syntax_options = "-T";
}

$self -> logger ("start perl $syntax_options -c for $uri\n") if ($Perl::LanguageServer::debug1) ;
if ($^O =~ /Win/)
{
# ($ret, $out, $errout) = $self -> run_open3 ($text, \@inc) ;
($ret, $out, $errout) = $self -> run_win32 ($text, \@inc) ;
}
else
{
$ret = run_cmd ([$self -> perlcmd, '-c', @inc],
$ret = run_cmd ([$self -> perlcmd, $syntax_options, '-c', @inc],
"<", \$text,
">", \$out,
"2>", \$errout)
-> recv ;
}

my $rc = $ret >> 8 ;
$self -> logger ("perl -c rc=$rc out=$out errout=$errout\n") if ($Perl::LanguageServer::debug1) ;
$self -> logger ("perl $syntax_options -c rc=$rc out=$out errout=$errout\n") if ($Perl::LanguageServer::debug1) ;

my @messages ;
if ($rc != 0)
Expand Down
6 changes: 6 additions & 0 deletions lib/Perl/LanguageServer/Workspace.pm
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ has 'perlinc' =>
is => 'rw',
) ;

has 'use_taint_for_syntax_check' =>
(
isa => 'Maybe[Bool]',
is => 'rw'
) ;

has 'show_local_vars' =>
(
isa => 'Maybe[Bool]',
Expand Down