Skip to content

Commit

Permalink
Choose bidi runner via globals
Browse files Browse the repository at this point in the history
  • Loading branch information
Lipen committed Feb 6, 2024
1 parent edbd76f commit ca1ebf3
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ import org.jacodb.taint.configuration.TaintMethodSink

private val logger = KotlinLogging.logger {}

internal object Globals {
internal var TAINTED_LOOP_BOUND_SINK = false
}

class TaintAnalyzer(
private val graph: JcApplicationGraph,
) : Analyzer<TaintFact, TaintEvent> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import kotlinx.coroutines.yield
import org.jacodb.analysis.engine.SummaryStorageImpl
import org.jacodb.analysis.engine.UnitResolver
import org.jacodb.analysis.engine.UnitType
import org.jacodb.analysis.graph.reversed
import org.jacodb.analysis.ifds2.ControlEvent
import org.jacodb.analysis.ifds2.Manager
import org.jacodb.analysis.ifds2.QueueEmptinessChanged
Expand Down Expand Up @@ -71,34 +72,37 @@ class TaintManager(
): TaintRunner {
check(unit !in runnerForUnit) { "Runner for $unit already exists" }

val analyzer = TaintAnalyzer(graph)
val runner = Runner(graph, analyzer, this@TaintManager, unitResolver, unit)
val runner = if (Globals.BIDI_RUNNER) {
BidiRunner(
manager = this@TaintManager,
unitResolver = unitResolver,
unit = unit,
{ manager ->
val analyzer = TaintAnalyzer(graph)
Runner(
graph = graph,
analyzer = analyzer,
manager = manager,
unitResolver = unitResolver,
unit = unit
)
},
{ manager ->
val analyzer = BackwardTaintAnalyzer(graph)
Runner(
graph = graph.reversed,
analyzer = analyzer,
manager = manager,
unitResolver = unitResolver,
unit = unit
)
}
)
} else {
val analyzer = TaintAnalyzer(graph)
Runner(graph, analyzer, this@TaintManager, unitResolver, unit)
}

// val runner = BidiRunner(
// manager = this@TaintManager,
// unitResolver = unitResolver,
// unit = unit,
// { manager ->
// val analyzer = TaintAnalyzer(graph)
// Runner(
// graph = graph,
// analyzer = analyzer,
// manager = manager,
// unitResolver = unitResolver,
// unit = unit
// )
// },
// { manager ->
// val analyzer = BackwardTaintAnalyzer(graph)
// Runner(
// graph = graph.reversed,
// analyzer = analyzer,
// manager = manager,
// unitResolver = unitResolver,
// unit = unit
// )
// }
// )
runnerForUnit[unit] = runner
return runner
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright 2022 UnitTestBot contributors (utbot.org)
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.jacodb.analysis.ifds2.taint

internal object Globals {
var BIDI_RUNNER = true
var TAINTED_LOOP_BOUND_SINK = false
}

0 comments on commit ca1ebf3

Please sign in to comment.