svf-lib 1.0.1783 → 1.0.1785

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,58 @@
1
+ //===- CFLSVFGBuilder.h -- Building SVFG for CFL--------------------------//
2
+ //
3
+ // SVF: Static Value-Flow Analysis
4
+ //
5
+ // Copyright (C) <2013-> <Yulei Sui>
6
+ //
7
+
8
+ // This program is free software: you can redistribute it and/or modify
9
+ // it under the terms of the GNU Affero General Public License as published by
10
+ // the Free Software Foundation, either version 3 of the License, or
11
+ // (at your option) any later version.
12
+
13
+ // This program is distributed in the hope that it will be useful,
14
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ // GNU Affero General Public License for more details.
17
+
18
+ // You should have received a copy of the GNU Affero General Public License
19
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+ //
21
+ //===----------------------------------------------------------------------===//
22
+
23
+ //
24
+ // Created by Xiao on 30/12/23.
25
+ //
26
+
27
+ #ifndef SVF_CFLSVFGBUILDER_H
28
+ #define SVF_CFLSVFGBUILDER_H
29
+
30
+ #include "SABER/SaberSVFGBuilder.h"
31
+
32
+ namespace SVF
33
+ {
34
+
35
+ class CFLSVFGBuilder: public SaberSVFGBuilder
36
+ {
37
+ public:
38
+ typedef Set<const SVFGNode*> SVFGNodeSet;
39
+ typedef Map<NodeID, PointsTo> NodeToPTSSMap;
40
+ typedef FIFOWorkList<NodeID> WorkList;
41
+
42
+ /// Constructor
43
+ CFLSVFGBuilder() = default;
44
+
45
+ /// Destructor
46
+ virtual ~CFLSVFGBuilder() = default;
47
+
48
+ protected:
49
+ /// Re-write create SVFG method
50
+ virtual void buildSVFG();
51
+
52
+ /// Remove Incoming Edge for strong-update (SU) store instruction
53
+ /// Because the SU node does not receive indirect value
54
+ virtual void rmIncomingEdgeForSUStore(BVDataPTAImpl* pta);
55
+ };
56
+
57
+ }
58
+ #endif //SVF_CFLSVFGBUILDER_H
@@ -33,7 +33,7 @@
33
33
 
34
34
  #include "CFL/CFLBase.h"
35
35
  #include "CFL/CFLStat.h"
36
- #include "SABER/SaberSVFGBuilder.h"
36
+ #include "CFL/CFLSVFGBuilder.h"
37
37
  #include "WPA/Andersen.h"
38
38
 
39
39
  namespace SVF
@@ -59,7 +59,7 @@ public:
59
59
  void buildCFLGraph();
60
60
 
61
61
  private:
62
- SaberSVFGBuilder memSSA;
62
+ CFLSVFGBuilder memSSA;
63
63
  SVFG* svfg;
64
64
  };
65
65
 
@@ -66,6 +66,7 @@ class SVFG : public VFG
66
66
  {
67
67
  friend class SVFGBuilder;
68
68
  friend class SaberSVFGBuilder;
69
+ friend class CFLSVFGBuilder;
69
70
  friend class TaintSVFGBuilder;
70
71
  friend class DDASVFGBuilder;
71
72
  friend class MTASVFGBuilder;
@@ -58,6 +58,9 @@ public:
58
58
  typedef FIFOWorkList<const SVFGNode*> VFWorkList; ///< worklist for value-flow guard computation
59
59
  typedef FIFOWorkList<const SVFBasicBlock*> CFWorkList; ///< worklist for control-flow guard computation
60
60
 
61
+ typedef SaberCondAllocator::SVFGNodeToSVFGNodeSetMap SVFGNodeToSVFGNodeSetMap;
62
+
63
+
61
64
  /// Constructor
62
65
  ProgSlice(const SVFGNode* src, SaberCondAllocator* pa, const SVFG* graph):
63
66
  root(src), partialReachable(false), fullReachable(false), reachGlob(false),
@@ -296,6 +299,14 @@ protected:
296
299
  finalCond = cond;
297
300
  }
298
301
 
302
+ /// Compute invalid branch condition stemming from removed strong update value-flow edges
303
+ Condition computeInvalidCondFromRemovedSUVFEdge(const SVFGNode * cur);
304
+
305
+ const SVFGNodeToSVFGNodeSetMap& getRemovedSUVFEdges() const
306
+ {
307
+ return pathAllocator->getRemovedSUVFEdges();
308
+ }
309
+
299
310
  private:
300
311
  SVFGNodeSet forwardslice; ///< the forward slice
301
312
  SVFGNodeSet backwardslice; ///< the backward slice
@@ -56,6 +56,7 @@ public:
56
56
  typedef Map<const SVFFunction*, BasicBlockSet> FunToExitBBsMap; ///< map a function to all its basic blocks calling program exit
57
57
  typedef Map<const SVFBasicBlock*, Condition> BBToCondMap; ///< map a basic block to its condition during control-flow guard computation
58
58
  typedef FIFOWorkList<const SVFBasicBlock*> CFWorkList; ///< worklist for control-flow guard computation
59
+ typedef Map<const SVFGNode*, Set<const SVFGNode*>> SVFGNodeToSVFGNodeSetMap;
59
60
 
60
61
 
61
62
  /// Constructor
@@ -239,6 +240,12 @@ public:
239
240
  setCondInst(condition, inst);
240
241
  negConds.set(condition.id());
241
242
  }
243
+
244
+ SVFGNodeToSVFGNodeSetMap & getRemovedSUVFEdges()
245
+ {
246
+ return removedSUVFEdges;
247
+ }
248
+
242
249
  private:
243
250
 
244
251
  /// Allocate path condition for every basic block
@@ -299,6 +306,7 @@ private:
299
306
  NodeBS negConds; ///bit vector for distinguish neg
300
307
  std::vector<Condition> conditionVec; /// vector storing z3expression
301
308
  static u32_t totalCondNum; /// a counter for fresh condition
309
+ SVFGNodeToSVFGNodeSetMap removedSUVFEdges;
302
310
 
303
311
  protected:
304
312
  BBCondMap bbConds; ///< map basic block to its successors/predecessors branch conditions
@@ -34,9 +34,12 @@
34
34
  #include "SVFIR/SVFValue.h"
35
35
  #include "Util/WorkList.h"
36
36
 
37
+
37
38
  namespace SVF
38
39
  {
39
40
 
41
+ class SaberCondAllocator;
42
+
40
43
  class SaberSVFGBuilder : public SVFGBuilder
41
44
  {
42
45
 
@@ -62,6 +65,11 @@ public:
62
65
  svfg->addActualParmVFGNode(pagNode, cs);
63
66
  }
64
67
 
68
+ void setSaberCondAllocator(SaberCondAllocator* allocator)
69
+ {
70
+ saberCondAllocator = allocator;
71
+ }
72
+
65
73
  protected:
66
74
  /// Re-write create SVFG method
67
75
  virtual void buildSVFG();
@@ -69,7 +77,7 @@ protected:
69
77
  /// Return TRUE if this is a strong update STORE statement.
70
78
  bool isStrongUpdate(const SVFGNode* node, NodeID& singleton, BVDataPTAImpl* pta);
71
79
 
72
- private:
80
+ protected:
73
81
  /// Remove direct value-flow edge to a dereference point for Saber source-sink memory error detection
74
82
  /// for example, given two statements: p = alloc; q = *p, the direct SVFG edge between them is deleted
75
83
  /// Because those edges only stand for values used at the dereference points but they can not pass the value to other definitions
@@ -77,7 +85,7 @@ private:
77
85
 
78
86
  /// Remove Incoming Edge for strong-update (SU) store instruction
79
87
  /// Because the SU node does not receive indirect value
80
- void rmIncomingEdgeForSUStore(BVDataPTAImpl* pta);
88
+ virtual void rmIncomingEdgeForSUStore(BVDataPTAImpl* pta);
81
89
 
82
90
  /// Add actual parameter SVFGNode for 1st argument of a deallocation like external function
83
91
  /// In order to path sensitive leak detection
@@ -97,6 +105,8 @@ private:
97
105
  PointsTo globs;
98
106
  /// Store all global SVFG nodes
99
107
  SVFGNodeSet globSVFGNodes;
108
+
109
+ SaberCondAllocator* saberCondAllocator;
100
110
  };
101
111
 
102
112
  } // End namespace SVF
@@ -0,0 +1,58 @@
1
+ //===- CFLSVFGBuilder.h -- Building SVFG for CFL--------------------------//
2
+ //
3
+ // SVF: Static Value-Flow Analysis
4
+ //
5
+ // Copyright (C) <2013-> <Yulei Sui>
6
+ //
7
+
8
+ // This program is free software: you can redistribute it and/or modify
9
+ // it under the terms of the GNU Affero General Public License as published by
10
+ // the Free Software Foundation, either version 3 of the License, or
11
+ // (at your option) any later version.
12
+
13
+ // This program is distributed in the hope that it will be useful,
14
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ // GNU Affero General Public License for more details.
17
+
18
+ // You should have received a copy of the GNU Affero General Public License
19
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+ //
21
+ //===----------------------------------------------------------------------===//
22
+
23
+ //
24
+ // Created by Xiao on 30/12/23.
25
+ //
26
+
27
+ #ifndef SVF_CFLSVFGBUILDER_H
28
+ #define SVF_CFLSVFGBUILDER_H
29
+
30
+ #include "SABER/SaberSVFGBuilder.h"
31
+
32
+ namespace SVF
33
+ {
34
+
35
+ class CFLSVFGBuilder: public SaberSVFGBuilder
36
+ {
37
+ public:
38
+ typedef Set<const SVFGNode*> SVFGNodeSet;
39
+ typedef Map<NodeID, PointsTo> NodeToPTSSMap;
40
+ typedef FIFOWorkList<NodeID> WorkList;
41
+
42
+ /// Constructor
43
+ CFLSVFGBuilder() = default;
44
+
45
+ /// Destructor
46
+ virtual ~CFLSVFGBuilder() = default;
47
+
48
+ protected:
49
+ /// Re-write create SVFG method
50
+ virtual void buildSVFG();
51
+
52
+ /// Remove Incoming Edge for strong-update (SU) store instruction
53
+ /// Because the SU node does not receive indirect value
54
+ virtual void rmIncomingEdgeForSUStore(BVDataPTAImpl* pta);
55
+ };
56
+
57
+ }
58
+ #endif //SVF_CFLSVFGBUILDER_H
@@ -32,7 +32,7 @@
32
32
 
33
33
  #include "CFL/CFLBase.h"
34
34
  #include "CFL/CFLStat.h"
35
- #include "SABER/SaberSVFGBuilder.h"
35
+ #include "CFL/CFLSVFGBuilder.h"
36
36
  #include "WPA/Andersen.h"
37
37
 
38
38
  namespace SVF
@@ -58,7 +58,7 @@ public:
58
58
  void buildCFLGraph();
59
59
 
60
60
  private:
61
- SaberSVFGBuilder memSSA;
61
+ CFLSVFGBuilder memSSA;
62
62
  SVFG* svfg;
63
63
  };
64
64
 
@@ -65,6 +65,7 @@ class SVFG : public VFG
65
65
  {
66
66
  friend class SVFGBuilder;
67
67
  friend class SaberSVFGBuilder;
68
+ friend class CFLSVFGBuilder;
68
69
  friend class TaintSVFGBuilder;
69
70
  friend class DDASVFGBuilder;
70
71
  friend class MTASVFGBuilder;
@@ -58,6 +58,8 @@ public:
58
58
  typedef FIFOWorkList<const SVFGNode*> VFWorkList; ///< worklist for value-flow guard computation
59
59
  typedef FIFOWorkList<const SVFBasicBlock*> CFWorkList; ///< worklist for control-flow guard computation
60
60
 
61
+ typedef SaberCondAllocator::SVFGNodeToSVFGNodeSetMap SVFGNodeToSVFGNodeSetMap;
62
+
61
63
  /// Constructor
62
64
  ProgSlice(const SVFGNode* src, SaberCondAllocator* pa, const SVFG* graph):
63
65
  root(src), partialReachable(false), fullReachable(false), reachGlob(false),
@@ -296,6 +298,14 @@ protected:
296
298
  finalCond = cond;
297
299
  }
298
300
 
301
+ /// Compute invalid branch condition stemming from removed strong update value-flow edges
302
+ Condition computeInvalidCondFromRemovedSUVFEdge(const SVFGNode * cur);
303
+
304
+ const SVFGNodeToSVFGNodeSetMap& getRemovedSUVFEdges() const
305
+ {
306
+ return pathAllocator->getRemovedSUVFEdges();
307
+ }
308
+
299
309
  private:
300
310
  SVFGNodeSet forwardslice; ///< the forward slice
301
311
  SVFGNodeSet backwardslice; ///< the backward slice
@@ -55,6 +55,7 @@ public:
55
55
  typedef Map<const SVFFunction*, BasicBlockSet> FunToExitBBsMap; ///< map a function to all its basic blocks calling program exit
56
56
  typedef Map<const SVFBasicBlock*, Condition> BBToCondMap; ///< map a basic block to its condition during control-flow guard computation
57
57
  typedef FIFOWorkList<const SVFBasicBlock*> CFWorkList; ///< worklist for control-flow guard computation
58
+ typedef Map<const SVFGNode*, Set<const SVFGNode*>> SVFGNodeToSVFGNodeSetMap;
58
59
 
59
60
  /// Constructor
60
61
  SaberCondAllocator();
@@ -236,6 +237,12 @@ public:
236
237
  setCondInst(condition, inst);
237
238
  negConds.set(condition.id());
238
239
  }
240
+
241
+ SVFGNodeToSVFGNodeSetMap & getRemovedSUVFEdges()
242
+ {
243
+ return removedSUVFEdges;
244
+ }
245
+
239
246
  private:
240
247
 
241
248
  /// Allocate path condition for every basic block
@@ -295,6 +302,7 @@ private:
295
302
  NodeBS negConds; ///bit vector for distinguish neg
296
303
  std::vector<Condition> conditionVec; /// vector storing z3expression
297
304
  static u32_t totalCondNum; /// a counter for fresh condition
305
+ SVFGNodeToSVFGNodeSetMap removedSUVFEdges;
298
306
 
299
307
  protected:
300
308
  BBCondMap bbConds; ///< map basic block to its successors/predecessors branch conditions
@@ -37,6 +37,8 @@
37
37
  namespace SVF
38
38
  {
39
39
 
40
+ class SaberCondAllocator;
41
+
40
42
  class SaberSVFGBuilder : public SVFGBuilder
41
43
  {
42
44
 
@@ -62,6 +64,11 @@ public:
62
64
  svfg->addActualParmVFGNode(pagNode, cs);
63
65
  }
64
66
 
67
+ void setSaberCondAllocator(SaberCondAllocator* allocator)
68
+ {
69
+ saberCondAllocator = allocator;
70
+ }
71
+
65
72
  protected:
66
73
  /// Re-write create SVFG method
67
74
  virtual void buildSVFG();
@@ -69,7 +76,7 @@ protected:
69
76
  /// Return TRUE if this is a strong update STORE statement.
70
77
  bool isStrongUpdate(const SVFGNode* node, NodeID& singleton, BVDataPTAImpl* pta);
71
78
 
72
- private:
79
+ protected:
73
80
  /// Remove direct value-flow edge to a dereference point for Saber source-sink memory error detection
74
81
  /// for example, given two statements: p = alloc; q = *p, the direct SVFG edge between them is deleted
75
82
  /// Because those edges only stand for values used at the dereference points but they can not pass the value to other definitions
@@ -77,7 +84,7 @@ private:
77
84
 
78
85
  /// Remove Incoming Edge for strong-update (SU) store instruction
79
86
  /// Because the SU node does not receive indirect value
80
- void rmIncomingEdgeForSUStore(BVDataPTAImpl* pta);
87
+ virtual void rmIncomingEdgeForSUStore(BVDataPTAImpl* pta);
81
88
 
82
89
  /// Add actual parameter SVFGNode for 1st argument of a deallocation like external function
83
90
  /// In order to path sensitive leak detection
@@ -97,6 +104,8 @@ private:
97
104
  PointsTo globs;
98
105
  /// Store all global SVFG nodes
99
106
  SVFGNodeSet globSVFGNodes;
107
+
108
+ SaberCondAllocator* saberCondAllocator;
100
109
  };
101
110
 
102
111
  } // End namespace SVF
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.1783",
3
+ "version": "1.0.1785",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {