Skip to content

Commit c979f65

Browse files
committed
JS: Move some alerts and add query IDs
1 parent 2ad7e3a commit c979f65

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

javascript/ql/test/query-tests/Security/CWE-830/DynamicCreationOfUntrustedSourceUse.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,25 @@
1313
scrpt2.src = 'http://www.cdn.local/ga.js';
1414
scrpt2.integrity = 'sha256-h0UuK3mE9taiYlB5u9vT9A0s/XDgkfVd+F4VhN/sky=';
1515

16-
var scrpt3 = document.createElement('script'); // $ Alert - http + ternary
16+
var scrpt3 = document.createElement('script');
1717
scrpt3.type = 'text/javascript';
18-
scrpt3.src = ('https:' == document.location.protocol ? 'http://unsafe' : 'http://also-unsafe') + '.cdn.local/ga.js';
18+
scrpt3.src = ('https:' == document.location.protocol ? 'http://unsafe' : 'http://also-unsafe') + '.cdn.local/ga.js'; // $ Alert[js/functionality-from-untrusted-source] - http + ternary
1919

20-
var ifrm = document.createElement('iframe'); // $ Alert - http URL
21-
ifrm.src = 'http://www.example.com/';
20+
var ifrm = document.createElement('iframe');
21+
ifrm.src = 'http://www.example.com/'; // $ Alert[js/functionality-from-untrusted-source] - http URL
2222

2323
// OK - https URL
2424
var ifrm2 = document.createElement('iframe');
2525
ifrm2.src = 'https://www.example.com/';
2626

27-
function getUrl(version) { // $ Alert - http URL tracked through calls
27+
function getUrl(version) {
2828
return 'http://www.cdn.local/'+version+'/ga.js';
2929
}
3030
var ifrm3 = document.createElement('iframe');
31-
ifrm3.src = getUrl('v123');
31+
ifrm3.src = getUrl('v123'); // $ Alert[js/functionality-from-untrusted-source] - http URL tracked through calls
3232

33-
var ifrm4 = document.createElement('iframe'); // $ Alert - assignment of bad URL using setAttribute
34-
ifrm4.setAttribute('src', 'http://www.example.local/page.html');
33+
var ifrm4 = document.createElement('iframe');
34+
ifrm4.setAttribute('src', 'http://www.example.local/page.html'); // $ Alert[js/functionality-from-untrusted-source] - assignment of bad URL using setAttribute
3535

3636
// OK - bad URL, but the attribute is not `src`
3737
var ifrm5 = document.createElement('iframe');
@@ -42,4 +42,4 @@
4242
<body>
4343
hello
4444
</body>
45-
</html>
45+
</html>

javascript/ql/test/query-tests/Security/CWE-830/StaticCreationOfUntrustedSourceUse.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
<!-- Some CDNs recommend using the integrity attribute — for those, we demand it even with https links -->
1818
<!-- OK - digest present -->
1919
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.8.2/angular.min.js" integrity="sha512-7oYXeK0OxTFxndh0erL8FsjGvrl2VMDor6fVqzlLGfwOQQqTbYsGPv4ZZ15QHfSk80doyaM0ZJdvkyDcVO7KFA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
20-
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.8.2/angular.min.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <!-- $ Alert - digest missing -->
20+
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.8.2/angular.min.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <!-- $ Alert[js/functionality-from-untrusted-source] - digest missing -->
2121
</body>
2222
</html>

0 commit comments

Comments
 (0)