| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c01db23 commit 61bd868
20 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,8 +26,6 @@ import semmle.python.web.HttpRequest | |||
| 26 | 26 | import semmle.python.security.injection.Path | |
| 27 | 27 | ||
| 28 | 28 | ||
| 29 | - | ||
| 30 | - from TaintedNode srcnode, TaintedNode sinknode, TaintSource src, TaintSink sink | ||
| 31 | - where src.flowsToSink(sink) and srcnode.getNode() = src and sinknode.getNode() = sink | ||
| 32 | - | ||
| 33 | - select sink, srcnode, sinknode, "This path depends on $@.", src, "a user-provided value" | ||
| 29 | + from TaintedPathSource src, TaintedPathSink sink | ||
| 30 | + where src.flowsTo(sink) | ||
| 31 | + select sink.getSink(), src, sink, "This path depends on $@.", src.getSource(), "a user-provided value" | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,7 +23,6 @@ import semmle.python.web.HttpRequest | |||
| 23 | 23 | /* Sinks */ | |
| 24 | 24 | import semmle.python.security.injection.Command | |
| 25 | 25 | ||
| 26 | - from TaintedNode srcnode, TaintedNode sinknode, TaintSource src, TaintSink sink | ||
| 27 | - where src.flowsToSink(sink) and srcnode.getNode() = src and sinknode.getNode() = sink | ||
| 28 | - | ||
| 29 | - select sink, srcnode, sinknode, "This command depends on $@.", src, "a user-provided value" | ||
| 26 | + from TaintedPathSource src, TaintedPathSink sink | ||
| 27 | + where src.flowsTo(sink) | ||
| 28 | + select sink.getSink(), src, sink, "This command depends on $@.", src.getSource(), "a user-provided value" | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,9 +25,6 @@ import semmle.python.web.HttpResponse | |||
| 25 | 25 | /* Flow */ | |
| 26 | 26 | import semmle.python.security.strings.Untrusted | |
| 27 | 27 | ||
| 28 | - from TaintedNode srcnode, TaintedNode sinknode, TaintSource src, TaintSink sink | ||
| 29 | - where src.flowsToSink(sink) and srcnode.getNode() = src and sinknode.getNode() = sink | ||
| 30 | - | ||
| 31 | - select sink, srcnode, sinknode, "Cross-site scripting vulnerability due to $@.", | ||
| 32 | - src, "user-provided value" | ||
| 33 | - | ||
| 28 | + from TaintedPathSource src, TaintedPathSink sink | ||
| 29 | + where src.flowsTo(sink) | ||
| 30 | + select sink.getSink(), src, sink, "Cross-site scripting vulnerability due to $@.", src.getSource(), "user-provided value" | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,7 +23,6 @@ import semmle.python.web.django.Db | |||
| 23 | 23 | import semmle.python.web.django.Model | |
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | - from TaintedNode srcnode, TaintedNode sinknode, TaintSource src, TaintSink sink | ||
| 27 | - where src.flowsToSink(sink) and srcnode.getNode() = src and sinknode.getNode() = sink | ||
| 28 | - | ||
| 29 | - select sink, srcnode, sinknode, "This SQL query depends on $@.", src, "a user-provided value" | ||
| 26 | + from TaintedPathSource src, TaintedPathSink sink | ||
| 27 | + where src.flowsTo(sink) | ||
| 28 | + select sink.getSink(), src, sink, "This SQL query depends on $@.", src.getSource(), "a user-provided value" | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,7 +24,6 @@ import semmle.python.web.HttpRequest | |||
| 24 | 24 | import semmle.python.security.injection.Exec | |
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | - from TaintedNode srcnode, TaintedNode sinknode, TaintSource src, TaintSink sink | ||
| 28 | - where src.flowsToSink(sink) and srcnode.getNode() = src and sinknode.getNode() = sink | ||
| 29 | - | ||
| 30 | - select sink, srcnode, sinknode, "$@ flows to here and is interpreted as code.", src, "User-provided value" | ||
| 27 | + from TaintedPathSource src, TaintedPathSink sink | ||
| 28 | + where src.flowsTo(sink) | ||
| 29 | + select sink.getSink(), src, sink, "$@ flows to here and is interpreted as code.", src.getSource(), "User-provided value" | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,6 +18,6 @@ import semmle.python.security.Paths | |||
| 18 | 18 | import semmle.python.security.Exceptions | |
| 19 | 19 | import semmle.python.web.HttpResponse | |
| 20 | 20 | ||
| 21 | - from TaintedNode srcnode, TaintedNode sinknode, TaintSource src, TaintSink sink | ||
| 22 | - where src.flowsToSink(sink) and srcnode.getNode() = src and sinknode.getNode() = sink | ||
| 23 | - select sink, srcnode, sinknode, "$@ may be exposed to an external user", src, "Error information" | ||
| 21 | + from TaintedPathSource src, TaintedPathSink sink | ||
| 22 | + where src.flowsTo(sink) | ||
| 23 | + select sink.getSink(), src, sink, "$@ may be exposed to an external user", src.getSource(), "Error information" | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,7 +25,6 @@ import semmle.python.security.injection.Marshal | |||
| 25 | 25 | import semmle.python.security.injection.Yaml | |
| 26 | 26 | ||
| 27 | 27 | ||
| 28 | - from TaintedNode srcnode, TaintedNode sinknode, TaintSource src, TaintSink sink | ||
| 29 | - where src.flowsToSink(sink) and srcnode.getNode() = src and sinknode.getNode() = sink | ||
| 30 | - | ||
| 31 | - select sink, srcnode, sinknode, "Deserializing of $@.", src, "untrusted input" | ||
| 28 | + from TaintedPathSource src, TaintedPathSink sink | ||
| 29 | + where src.flowsTo(sink) | ||
| 30 | + select sink.getSink(), src, sink, "Deserializing of $@.", src.getSource(), "untrusted input" | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -28,8 +28,7 @@ class UntrustedPrefixStringKind extends UntrustedStringKind { | |||
| 28 | 28 | ||
| 29 | 29 | } | |
| 30 | 30 | ||
| 31 | - from TaintedNode srcnode, TaintedNode sinknode, TaintSource src, TaintSink sink | ||
| 32 | - where src.flowsToSink(sink) and srcnode.getNode() = src and sinknode.getNode() = sink | ||
| 33 | - | ||
| 34 | - select sink, srcnode, sinknode, "Untrusted URL redirection due to $@.", src, "a user-provided value" | ||
| 31 | + from TaintedPathSource src, TaintedPathSink sink | ||
| 32 | + where src.flowsTo(sink) | ||
| 33 | + select sink.getSink(), src, sink, "Untrusted URL redirection due to $@.", src.getSource(), "a user-provided value" | ||
| 35 | 34 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,6 +24,11 @@ class ExceptionInfo extends StringKind { | |||
| 24 | 24 | ExceptionInfo() { | |
| 25 | 25 | this = "exception.info" | |
| 26 | 26 | } | |
| 27 | + | ||
| 28 | + override string repr() { | ||
| 29 | + result = "exception info" | ||
| 30 | + } | ||
| 31 | + | ||
| 27 | 32 | } | |
| 28 | 33 | ||
| 29 | 34 | ||
@@ -36,6 +41,10 @@ class ExceptionKind extends TaintKind { | |||
| 36 | 41 | this = "exception.kind" | |
| 37 | 42 | } | |
| 38 | 43 | ||
| 44 | + override string repr() { | ||
| 45 | + result = "exception" | ||
| 46 | + } | ||
| 47 | + | ||
| 39 | 48 | override TaintKind getTaintOfAttribute(string name) { | |
| 40 | 49 | name = "args" and result instanceof ExceptionInfoSequence | |
| 41 | 50 | or | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -148,6 +148,8 @@ abstract class TaintKind extends string { | |||
| 148 | 148 | none() | |
| 149 | 149 | } | |
| 150 | 150 | ||
| 151 | + string repr() { result = this } | ||
| 152 | + | ||
| 151 | 153 | } | |
| 152 | 154 | ||
| 153 | 155 | /** Taint kinds representing collections of other taint kind. | |
@@ -208,6 +210,10 @@ class SequenceKind extends CollectionKind { | |||
| 208 | 210 | name = "pop" and result = this.getItem() | |
| 209 | 211 | } | |
| 210 | 212 | ||
| 213 | + override string repr() { | ||
| 214 | + result = "sequence of " + itemKind | ||
| 215 | + } | ||
| 216 | + | ||
| 211 | 217 | } | |
| 212 | 218 | ||
| 213 | 219 | /* Helper for getTaintForStep() */ | |
@@ -281,6 +287,10 @@ class DictKind extends CollectionKind { | |||
| 281 | 287 | name = "itervalues" and result.(SequenceKind).getItem() = valueKind | |
| 282 | 288 | } | |
| 283 | 289 | ||
| 290 | + override string repr() { | ||
| 291 | + result = "dict of " + valueKind | ||
| 292 | + } | ||
| 293 | + | ||
| 284 | 294 | } | |
| 285 | 295 | ||
| 286 | 296 | ||
@@ -603,7 +613,9 @@ private predicate user_tainted_def(TaintedDefinition def, TaintFlowImplementatio | |||
| 603 | 613 | */ | |
| 604 | 614 | class TaintedNode extends TTaintedNode { | |
| 605 | 615 | ||
| 606 | - string toString() { result = this.getTrackedValue().toString() + " at " + this.getLocation() } | ||
| 616 | + string toString() { result = this.getTrackedValue().repr() } | ||
| 617 | + | ||
| 618 | + string debug() { result = this.getTrackedValue().toString() + " at " + this.getNode().getLocation() } | ||
| 607 | 619 | ||
| 608 | 620 | TaintedNode getASuccessor() { | |
| 609 | 621 | exists(TaintFlowImplementation::TrackedValue tokind, CallContext tocontext, ControlFlowNode tonode | | |
@@ -675,25 +687,33 @@ class TaintedNode extends TTaintedNode { | |||
| 675 | 687 | ||
| 676 | 688 | } | |
| 677 | 689 | ||
| 678 | - class TaintedNodeSource extends TaintedNode { | ||
| 690 | + class TaintedPathSource extends TaintedNode { | ||
| 679 | 691 | ||
| 680 | - TaintedNodeSource() { | ||
| 692 | + TaintedPathSource() { | ||
| 681 | 693 | this.getNode().(TaintSource).isSourceOf(this.getTaintKind(), this.getContext()) | |
| 682 | 694 | } | |
| 683 | 695 | ||
| 684 | 696 | /** Holds if taint can flow from this source to sink `sink` */ | |
| 685 | - final predicate flowsTo(TaintedNodeSink sink) { | ||
| 697 | + final predicate flowsTo(TaintedPathSink sink) { | ||
| 686 | 698 | this.getASuccessor*() = sink | |
| 687 | 699 | } | |
| 688 | 700 | ||
| 701 | + TaintSource getSource() { | ||
| 702 | + result = this.getNode() | ||
| 703 | + } | ||
| 704 | + | ||
| 689 | 705 | } | |
| 690 | 706 | ||
| 691 | - class TaintedNodeSink extends TaintedNode { | ||
| 707 | + class TaintedPathSink extends TaintedNode { | ||
| 692 | 708 | ||
| 693 | - TaintedNodeSink() { | ||
| 709 | + TaintedPathSink() { | ||
| 694 | 710 | this.getNode().(TaintSink).sinks(this.getTaintKind()) | |
| 695 | 711 | } | |
| 696 | 712 | ||
| 713 | + TaintSink getSink() { | ||
| 714 | + result = this.getNode() | ||
| 715 | + } | ||
| 716 | + | ||
| 697 | 717 | } | |
| 698 | 718 | ||
| 699 | 719 | /** This module contains the implementation of taint-flow. | |
@@ -739,12 +759,18 @@ library module TaintFlowImplementation { | |||
| 739 | 759 | ||
| 740 | 760 | abstract string toString(); | |
| 741 | 761 | ||
| 762 | + abstract string repr(); | ||
| 763 | + | ||
| 742 | 764 | abstract TrackedValue toKind(TaintKind kind); | |
| 743 | 765 | ||
| 744 | 766 | } | |
| 745 | 767 | ||
| 746 | 768 | class TrackedTaint extends TrackedValue, TTrackedTaint { | |
| 747 | 769 | ||
| 770 | + override string repr() { | ||
| 771 | + result = this.getKind().repr() | ||
| 772 | + } | ||
| 773 | + | ||
| 748 | 774 | override string toString() { | |
| 749 | 775 | result = "Taint " + this.getKind() | |
| 750 | 776 | } | |
@@ -761,6 +787,13 @@ library module TaintFlowImplementation { | |||
| 761 | 787 | ||
| 762 | 788 | class TrackedAttribute extends TrackedValue, TTrackedAttribute { | |
| 763 | 789 | ||
| 790 | + override string repr() { | ||
| 791 | + exists(string name, TaintKind kind | | ||
| 792 | + this = TTrackedAttribute(name, kind) and | ||
| 793 | + result = "." + name + "=" + kind.repr() | ||
| 794 | + ) | ||
| 795 | + } | ||
| 796 | + | ||
| 764 | 797 | override string toString() { | |
| 765 | 798 | exists(string name, TaintKind kind | | |
| 766 | 799 | this = TTrackedAttribute(name, kind) and | |
| Back | FazBrowse Home | New Git URL |
0 commit comments