Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Applications
tor-browser-bundle-testsuite
Commits
3178db78
Unverified
Commit
3178db78
authored
Oct 24, 2016
by
boklm
Browse files
Bug 15138: Add an otool_PIE test
Add a test to check that executables included in the OSX bundle are PIE.
parent
09fad922
Changes
1
Show whitespace changes
Inline
Side-by-side
TBBTestSuite/TestSuite/BrowserBundleTests.pm
View file @
3178db78
...
...
@@ -16,6 +16,7 @@ use File::Temp;
use
JSON
;
use
Digest::
SHA
qw(sha256_hex)
;
use
LWP::
UserAgent
;
use
IO::
CaptureOutput
qw(capture_exec)
;
use
TBBTestSuite::
Common
qw(exit_error winpath clone_strip_coderef screenshot_thumbnail)
;
use
TBBTestSuite::
Options
qw($options)
;
use
TBBTestSuite::Tests::
VirusTotal
qw(virustotal_run)
;
...
...
@@ -99,6 +100,22 @@ our @tests = (
check_output
=>
sub
{
!
(
$_
[
0
]
=~
m/runpath/
)
},
enable
=>
sub
{
$OSNAME
eq
'
linux
'
},
},
{
name
=>
'
otool_PIE
',
type
=>
'
command
',
descr
=>
'
Check for PIE support
',
files
=>
\
&tbb_osx_executable_files
,
command
=>
[
'
otool
',
'
-hv
'
],
check_output
=>
sub
{
my
@lines
=
split
("
\n
",
$_
[
0
]);
my
$last_line
=
pop
@lines
;
my
(
$flags
)
=
$last_line
=~
m/^\s*[^\s]+\s+[^\s]+\s+[^\s]+\s+[^\s]+\s+[^\s]+\s+[^\s]+\s+[^\s]+\s+(.*)/
;
my
%flags
=
map
{
$_
=>
1
}
split
(
/\s+/
,
$flags
);
return
$flags
{
PIE
};
},
enable
=>
sub
{
$OSNAME
eq
'
darwin
'
},
retry
=>
1
,
},
{
name
=>
'
tor_httpproxy
',
type
=>
'
tor_bootstrap
',
...
...
@@ -507,6 +524,27 @@ sub tbb_binfiles {
return
$tbbinfos
->
{
binfiles
}
=
[
keys
%binfiles
];
}
sub
tbb_osx_executable_files
{
my
(
$tbbinfos
,
$test
)
=
@_
;
return
$tbbinfos
->
{
osx_executable_files
}
if
$tbbinfos
->
{
osx_executable_files
};
my
%exec_files
;
my
$wanted
=
sub
{
return
unless
-
f
$
File::Find::
name
;
$ENV
{
LC_ALL
}
=
'
C
';
my
(
$out
,
$err
,
$success
)
=
capture_exec
('
otool
',
'
-hv
',
$
File::Find::
name
);
return
unless
$success
;
my
@out_lines
=
split
("
\n
",
$out
);
return
if
$out_lines
[
0
]
=~
m/is not an object file/
;
my
$last_line
=
pop
@out_lines
;
my
(
$type
)
=
$last_line
=~
m/^\s*[^\s]+\s+[^\s]+\s+[^\s]+\s+[^\s]+\s+([^\s]+)\s+[^\s]+\s+[^\s]+\s+/
;
my
$name
=
$
File::Find::
name
;
$name
=~
s/^$tbbinfos->{tbbdir}\///
;
$exec_files
{
$name
}
=
1
if
$type
eq
'
EXECUTE
';
};
find
(
$wanted
,
$tbbinfos
->
{
tbbdir
});
return
$tbbinfos
->
{
osx_executable_files
}
=
[
keys
%exec_files
];
}
sub
list_tests
{
foreach
my
$test
(
@tests
)
{
print
"
$test
->{name} (
$test
->{type})
\n
$test
->{descr}
\n\n
";
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment