Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions javascript/ql/src/Summary/TaintSinks.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* @name Taint sinks
* @description Expressions that are vulnerable if containing untrusted data.
* @kind problem
* @problem.severity info
* @id js/summary/taint-sinks
* @tags summary
* @precision medium
*/

import javascript
import meta.internal.TaintMetrics

from string kind
select relevantTaintSink(kind), kind + " sink"
16 changes: 16 additions & 0 deletions javascript/ql/src/Summary/TaintSources.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* @name Taint sources
* @description Sources of untrusted input.
* @kind problem
* @problem.severity info
* @id js/summary/taint-sources
* @tags summary
* @precision medium
*/

import javascript
import meta.internal.TaintMetrics

from RemoteFlowSource node
where node = relevantTaintSource()
Comment on lines +14 to +15
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

relevantTaintSource has return-type DataFlow::Node, so I think the node here should have that type.

Suggested change
from RemoteFlowSource node
where node = relevantTaintSource()
from DataFlow::Node node
where node = relevantTaintSource()

Or relevantTaintSource could be changed to have the return-type RemoteFlowSource.
DOM::locationSource() is a RemoteFlowSource anyway, so relevantTaintSource could be simplified in the same go.

select node, node.getSourceType()
11 changes: 2 additions & 9 deletions javascript/ql/src/meta/internal/TaintMetrics.qll
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,9 @@ DataFlow::Node relevantTaintSink(string kind) {
DataFlow::Node relevantTaintSink() { result = relevantTaintSink(_) }

/**
* Gets a remote flow source or `document.location` source.
* Gets a relevant remote flow source.
*/
DataFlow::Node relevantTaintSource() {
not result.getFile() instanceof IgnoredFile and
(
result instanceof RemoteFlowSource
or
result = DOM::locationSource()
)
}
RemoteFlowSource relevantTaintSource() { not result.getFile() instanceof IgnoredFile }

/**
* Gets the output of a call that shows intent to sanitize a value
Expand Down