Repository navigation
[Taint-Analysis] Set Lift - #2799
EagleoutIce wants to merge 19 commits into
Conversation
| return this.create(this._value); | ||
| } | ||
|
|
||
| get elements(): ReadonlySet<Elements[number]> { |
There was a problem hiding this comment.
klassisch gesehen ist das die domain
| value: Elements[number] | SetLiftValue<Elements[number]> = new Set() | ||
| ) { | ||
| const lifted: SetLiftValue<Elements[number]> = | ||
| typeof value === 'symbol' |
There was a problem hiding this comment.
das ist too specific imho - also du musst hier davon ausgehen dass es wenn es noch kein set lift hat, keine Unterscheidung auf dem.. Wert stattfinden muss? also du willst hier ja eigentlich checkne ob das value atomar ist oder nicht. Aber für dich sind alle Werte die du da kriegst schon atomar sonst muss man komplexer kodieren was es schon "partially" als set lift gibt etc. und braucht einen anderen constructor
There was a problem hiding this comment.
Wenn ich hier aber nur atomare Werte annehme kann ich in der create function nicht mehr this mit "as this" zurückgeben, weil ich da ja eine instanz von SetLiftDomain mit einem Set als value erstelle
There was a problem hiding this comment.
das ollte schon gehen tbh man kann das ja guarden und dann casten in der Funktion. Also ich finds ok als restriction die iwr aber mit der Zeit entfernen wollen
|
|
||
| protected equalsValue(this: SetLiftDomain<Top, Bottom, Elements>, other: SetLiftDomain<Top, Bottom, Elements>): boolean { | ||
| return this.value.size === other.value.size | ||
| && [...this.value].every(element => other.value.has(element)); |
There was a problem hiding this comment.
du kannst eig bei sets .intersect usw. checken! auch symmetric differnces usw.
| isValue(): this is this & AbstractDomain<SetLiftValue<Elements[number]>, SetLiftTop<Elements[number]>, SetLiftBottom<Elements[number]>, SetLiftValue<Elements[number]>> { | ||
| // return !this.isBottom() && !this.isTop(); //Linter does not like this | ||
| return !(this.isSingletonEqual(this.base.baseBottom.value) || this.value.size === 0) | ||
| && !(this.isSingletonEqual(this.base.baseTop.value) || this.isFullSet(this.value)); |
There was a problem hiding this comment.
das wirkt noch ein wenig umständlich aber von der Umsetzung sollte es korrekt sein :)
introduce a more complex lattice to test setlift specific behaviour
add documentation for private function of setLiftDomain
| const E = Symbol('E'); | ||
| const F = Symbol('F'); | ||
|
|
||
| const lattice = new FiniteDomainBuilder() // Top |
There was a problem hiding this comment.
for later: this sis genrally something where we probably wnat mutation tets because this can be systematizied
|
|
||
| export const securityDomainLifted = securityDomain.setLift(); | ||
|
|
||
| export const UserInputLifted = securityDomainLifted.create(UserInput).value; |
There was a problem hiding this comment.
Given this is a monadic set structure I am not so sure whether
- we want the
.valueaccess I'd expect that to be transparent - we need the re-creation. I mean yes for tests against the actual underlying representation thats fine but we should mostly test on the scope of the lattice equality
There was a problem hiding this comment.
just to be clear - you mean this in the sense of:
- using .equals instead of comparing the values directly in the tests (or completely disallowing .value accesses)
- mostly copied this from the existing security-analysis.ts but we can discuss how i could refactor my new and the existing tests :D
| ? BottomLifted | ||
| : taints.length > 0 ? AbstractDomain.joinAll(taints).value : TopLifted; | ||
|
|
||
| export const securityAnalysisLifted = TaintAnalysisDefinition.create('security', securityDomainLifted) |
There was a problem hiding this comment.
so technically the idea would be to not duplicate all of this.
but either have a securityAnalysis.backing(securityDomainLifted)
or to propagate it to lift. Like the implementation(s) of the analysis should be the exact same no matter whether we lift the structure or not.
Theoretically it should also be able to (dep injection style) lift them only when doing the actual analysis!
There was a problem hiding this comment.
in the sense of providing another method like .lift() on the analysis itself, that lifts its domain to a SetLiftDomain and adjust all conditionFn and taints to its corresponding lifted counterparts
OR
should analyses be defined in a way that is agnostic about the lift state of its domain? e.g. taints and conditionFn should not need any adjustment when lifting the domain
There was a problem hiding this comment.
yes :P
the anlysis should be agnostic of whether they are lifted (or embedded to a sublattice etc.) and I also want a .lift on the lattice which makes the analysis treats it like a set
| @@ -24,7 +24,7 @@ export const securityDomain = new FiniteDomainBuilder<Top, Bottom, [Top, Bottom, | |||
| .build(); | |||
|
|
|||
| /** Matches network protocols in a path argument. */ | |||
| const NetworkProtocolRegex = /^(https?|ftps?):\/\//; | |||
| export const NetworkProtocolRegex = /^(https?|ftps?):\/\//; | |||
There was a problem hiding this comment.
Side note: this should go as well. Not necessarily in this issue. But we have the network linting rule and by extend the input classifier which has a regex like this... Just much more sensitive :D
| await testTaintAnalysis(code, securityAnalysisLifted, expectation); | ||
| }); | ||
| } | ||
| describe('Lifted Security Taint Analysis', () => { |
There was a problem hiding this comment.
for these, also check out the input-classifier tests that we have in flowR!
| @@ -16,7 +16,7 @@ import type { MultiValueDomain } from '../../../src/abstract-interpretation/doma | |||
| import type { TaintProduct } from '../../../src/taint-analysis/taint-visitor'; | |||
| import type { TaintAnalysisBuilder } from '../../../src/taint-analysis/builder/taint-analysis'; | |||
|
|
|||
| export type TaintAnalysisExpectation = Record<SlicingCriterion, symbol | undefined>; | |||
| export type TaintAnalysisExpectation = Record<SlicingCriterion, symbol | undefined>; // | Set<symbol> | |||
There was a problem hiding this comment.
wanted to leave this as a hint that i want to add it - but adding this will needs some more minor adjustments :D
No description provided.