Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cwe_checker
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fact-depend
cwe_checker
Commits
4034acbb
Commit
4034acbb
authored
Jul 19, 2019
by
Thomas Barabosch
Committed by
Enkelmann
Jul 19, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed CWE367: use symbols defined in config.json (#28)
parent
08951c01
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
24 deletions
+30
-24
CHANGES.md
CHANGES.md
+1
-0
cwe_367.ml
src/checkers/cwe_367.ml
+29
-24
No files found.
CHANGES.md
View file @
4034acbb
...
@@ -2,6 +2,7 @@ dev
...
@@ -2,6 +2,7 @@ dev
====
====
-
Added more documentation to checks (PR #26)
-
Added more documentation to checks (PR #26)
-
Fixed check CWE367: use symbols defined in config.json (PR #28)
0.
2 (2019-06-25)
0.
2 (2019-06-25)
=====
=====
...
...
src/checkers/cwe_367.ml
View file @
4034acbb
...
@@ -34,29 +34,34 @@ let is_reachable sub source sink =
...
@@ -34,29 +34,34 @@ let is_reachable sub source sink =
let
sink_blk
=
get_blk_tid_of_tid
sub
sink_tid
in
let
sink_blk
=
get_blk_tid_of_tid
sub
sink_tid
in
Graphlib
.
Std
.
Graphlib
.
is_reachable
(
module
Graphs
.
Tid
)
cfg
source_blk
sink_blk
Graphlib
.
Std
.
Graphlib
.
is_reachable
(
module
Graphs
.
Tid
)
cfg
source_blk
sink_blk
let
handle_sub
sub
program
tid_map
_symbols
source
sink
=
let
handle_sub
sub
program
tid_map
_symbols
source_sink_pair
=
if
(
Symbol_utils
.
sub_calls_symbol
program
sub
source
)
&&
(
Symbol_utils
.
sub_calls_symbol
program
sub
sink
)
then
match
source_sink_pair
with
begin
|
[
source
;
sink
;]
->
begin
let
calls
=
Symbol_utils
.
get_direct_callsites_of_sub
sub
in
if
(
Symbol_utils
.
sub_calls_symbol
program
sub
source
)
&&
(
Symbol_utils
.
sub_calls_symbol
program
sub
sink
)
then
let
source_calls
=
get_calls_to_symbol
source
calls
program
in
begin
let
sink_calls
=
get_calls_to_symbol
sink
calls
program
in
let
calls
=
Symbol_utils
.
get_direct_callsites_of_sub
sub
in
Seq
.
iter
source_calls
~
f
:
(
fun
source_call
->
let
source_calls
=
get_calls_to_symbol
source
calls
program
in
Seq
.
iter
sink_calls
~
f
:
(
fun
sink_call
->
let
sink_calls
=
get_calls_to_symbol
sink
calls
program
in
if
is_reachable
sub
source_call
sink_call
then
Seq
.
iter
source_calls
~
f
:
(
fun
source_call
->
Log_utils
.
warn
Seq
.
iter
sink_calls
~
f
:
(
fun
sink_call
->
"[%s] {%s} (Time-of-check Time-of-use Race Condition) %s is reachable from %s at %s (%s). This could lead to a TOCTOU."
if
is_reachable
sub
source_call
sink_call
then
name
Log_utils
.
warn
version
"[%s] {%s} (Time-of-check Time-of-use Race Condition) %s is reachable from %s at %s (%s). This could lead to a TOCTOU."
sink
name
source
version
(
Address_translation
.
translate_tid_to_assembler_address_string
(
Term
.
tid
sub
)
tid_map
)
sink
(
Term
.
name
sub
)
source
else
(
Address_translation
.
translate_tid_to_assembler_address_string
(
Term
.
tid
sub
)
tid_map
)
()
))
(
Term
.
name
sub
)
else
()
))
end
else
()
end
end
else
|
_
->
()
()
let
check_cwe
program
_proj
tid_map
_symbol_pairs
_
=
let
check_cwe
program
_proj
tid_map
symbol_pairs
_
=
let
symbols
=
Symbol_utils
.
build_symbols
[
"access"
;
"open"
;]
in
List
.
iter
symbol_pairs
~
f
:
(
fun
current_pair
->
Seq
.
iter
(
Term
.
enum
sub_t
program
)
~
f
:
(
fun
s
->
handle_sub
s
program
tid_map
symbols
"access"
"open"
)
let
symbols
=
Symbol_utils
.
build_symbols
current_pair
in
Seq
.
iter
(
Term
.
enum
sub_t
program
)
~
f
:
(
fun
s
->
handle_sub
s
program
tid_map
symbols
current_pair
))
Write
Preview
Markdown
is supported
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