Skip to content

Commit 97edfc5

Browse files
author
Esben Sparre Andreasen
committed
JS: address review comments
1 parent 80a716f commit 97edfc5

File tree

2 files changed

+18
-2
lines changed
  • javascript/ql/src/semmle/javascript

2 files changed

+18
-2
lines changed

javascript/ql/src/semmle/javascript/frameworks/Vue.qll

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ module Vue {
416416
module Template {
417417
// Currently only supports HTML elements, but it may be possible to parse simple string templates later
418418
private newtype TElement =
419-
MkHtmlElement(HTML::Element e) { exists(VueFile f | e.getFile() = f) }
419+
MkHtmlElement(HTML::Element e) { e.getFile() instanceof VueFile }
420420

421421
/**
422422
* An element of a template.
@@ -430,7 +430,7 @@ module Vue {
430430
* The location spans column `startcolumn` of line `startline` to
431431
* column `endcolumn` of line `endline` in file `filepath`.
432432
* For more information, see
433-
* [LGTM locations](https://lgtm.com/help/ql/locations).
433+
* [locations](https://help.semmle.com/QL/learn-ql/ql/locations.html).
434434
*/
435435
predicate hasLocationInfo(
436436
string filepath, int startline, int startcolumn, int endline, int endcolumn
@@ -442,6 +442,11 @@ module Vue {
442442
endcolumn = 0
443443
}
444444

445+
/**
446+
* Gets the name of this element.
447+
*
448+
* For example, the name of `<br>` is `br`.
449+
*/
445450
abstract string getName();
446451
}
447452

@@ -461,6 +466,9 @@ module Vue {
461466

462467
override string getName() { result = elem.getName() }
463468

469+
/**
470+
* Gets the HTML element of this element.
471+
*/
464472
HTML::Element getElement() { result = elem }
465473
}
466474
}

javascript/ql/src/semmle/javascript/security/dataflow/Xss.qll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ module DomBasedXss {
204204
class VHtmlSink extends DomBasedXss::Sink {
205205
HTML::Attribute attr;
206206
VHtmlSink() { this.(DataFlow::HtmlAttributeNode).getAttribute() = attr and attr.getName() = "v-html" }
207+
208+
/**
209+
* Gets the HTML attribute of this sink.
210+
*/
207211
HTML::Attribute getAttr() {
208212
result = attr
209213
}
@@ -212,6 +216,10 @@ module DomBasedXss {
212216
/**
213217
* A taint propagating data flow edge through a string interpolation of a
214218
* Vue instance property to a `v-html` attribute.
219+
*
220+
* As an example, `<div v-html="prop"/>` reads the `prop` property
221+
* of `inst = new Vue({ ..., data: { prop: source } })`, if the
222+
* `div` element is part of the template for `inst`.
215223
*/
216224
class VHtmlSourceWrite extends TaintTracking::AdditionalTaintStep {
217225
VHtmlSink attr;

0 commit comments

Comments
 (0)