### DigitalOcean Credentials Authentication Example Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/frameworks/DigitalOcean.qll/type Demonstrates the usage of the DigitalOcean::Credentials class for authentication with DigitalOcean, showing the typical pattern of calling the client with a token. ```javascript digitalocean.client() ``` -------------------------------- ### Get Start Location of Data Flow Node in JavaScript Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/security/dataflow/ImproperCodeSanitizationCustomizations.qll/type Gets the start column and start line of a data flow node in JavaScript. ```javascript getStartColumn| Gets the start column of this data flow node. | from Node ``` ```javascript getStartLine| Gets the start line of this data flow node. | from Node ``` -------------------------------- ### CodeQL Data Flow Configuration - Load/Store Steps Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/security/dataflow/SecondOrderCommandInjectionQuery.qll/type These experimental predicates, `isAdditionalLoadStep` and `isAdditionalLoadStoreStep`, are used to define custom data flow steps related to loading and storing data. They are marked as experimental and may change in future versions. ```javascript isAdditionalLoadStep() isAdditionalLoadStoreStep() isAdditionalLoadStoreStep() isAdditionalStoreStep() ``` -------------------------------- ### Get Start Basic Block Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/AST.qll/type Inherited from `StmtContainer`, this predicate gets the start basic block of the function, containing the start node of its CFG. ```ql getStartBB()| Gets the start basic block of this function, that is, the basic block containing the start node of its CFG. | from StmtContainer ``` -------------------------------- ### CodeQL Data Flow Configuration - Load/Store Steps Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/security/dataflow/DeepObjectResourceExhaustionQuery.qll/type These experimental predicates, `isAdditionalLoadStep` and `isAdditionalLoadStoreStep`, are used to define custom data flow steps related to loading and storing data. They are marked as experimental and may change in future versions. ```javascript isAdditionalLoadStep() isAdditionalLoadStoreStep() isAdditionalLoadStoreStep() isAdditionalStoreStep() ``` -------------------------------- ### Get Start Line Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/frameworks/Fastify.qll/type Gets the start line of a data flow node. ```javascript getStartLine() ``` -------------------------------- ### Get Start Column Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/frameworks/Fastify.qll/type Gets the start column of a data flow node. ```javascript getStartColumn() ``` -------------------------------- ### Working with Spife Applications in JavaScript Source: https://codeql.github.com/codeql-standard-libraries/javascript/javascript.qll/module Provides classes for working with Spife applications. Spife is a framework for building web services, and this library helps in analyzing its structure and behavior. ```javascript // Conceptual example of Spife application structure import { SpifeApp } from 'spife'; const app = new SpifeApp(); app.get('/', (req, res) => { res.send('Hello from Spife!'); }); app.listen(3000); ``` -------------------------------- ### Import JavaScript Library Source: https://codeql.github.com/codeql-standard-libraries/javascript/javascript.qll/module Demonstrates how to import the CodeQL JavaScript library for use in analysis. ```javascript import javascript ``` -------------------------------- ### Get Start Line of Locatable Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/TypeAnnotations.qll/type Gets the line number on which this locatable element starts. ```javascript getStartLine() ``` -------------------------------- ### Import JavaScript Concepts Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/Concepts.qll/module This snippet shows how to import the abstract concepts for working with JavaScript programs, including file system access and system command execution, from the CodeQL library. ```javascript import semmle.javascript.Concepts ``` -------------------------------- ### Get Route Setup Node in JavaScript/TypeScript Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/Routing.qll/predicate.Routing%24Routing%24getRouteSetupNode The `getRouteSetupNode` predicate in the CodeQL JavaScript library retrieves the routing node corresponding to a route installed in a route setup. It takes a `Node` representing the call to the route setup method as input and returns the relevant routing node. This is useful for understanding route configurations, especially when the route setup method returns a chainable value like the router itself. ```javascript import javascript /** * Gets the routing node corresponding to the route installed at the given route setup. * This is not generally the same as `getNode(call)`, since the route setup method can return a value that does not correspond to the route that was just installed. * Typically this occurs when the route setup method is chainable and returns the router itself. * * @param call The node representing the call to the route setup method. * @returns The routing node corresponding to the route setup. */ Node getRouteSetupNode(Node call) ``` -------------------------------- ### Get Start Line of Element Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/frameworks/LazyCache.qll/type Gets the line number on which a CodeQL element starts. Useful for pinpointing the location of code constructs in the source file. ```javascript getStartLine| Gets the line on which this element starts. | from Locatable ``` -------------------------------- ### JavaScript Toplevel Preamble CFG Example Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/CFG.qll/module Demonstrates the CFG for a JavaScript module, highlighting the preamble which includes import specifiers and hoisted functions before the module body and exit. ```javascript s import x as y from 'foo'; function f() {} t ``` ```text [entry] → [x as y] → [f] → [s] → [import x as y from 'foo';] → [function f() {}] → [t] → [exit] ``` -------------------------------- ### Get Start Line of Element Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/Tokens.qll/type Retrieves the line number on which the element starts. ```javascript getStartLine() ``` -------------------------------- ### Import InsecureDownloadCustomizations in JavaScript/TypeScript Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/security/dataflow/InsecureDownloadCustomizations.qll/module This snippet shows how to import the `InsecureDownloadCustomizations` module from the CodeQL standard library for JavaScript and TypeScript. This module provides default configurations for security analysis related to insecure file downloads. ```javascript import semmle.javascript.security.dataflow.InsecureDownloadCustomizations ``` -------------------------------- ### Get Start Line Number - CodeQL JavaScript Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/frameworks/React.qll/type Determines the starting line number of a locatable element. ```javascript getStartLine()| Gets the line on which this element starts. | from Locatable ``` -------------------------------- ### JavaScript Function Example for Data Flow Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/dataflow/Configuration.qll/module This example illustrates a simple JavaScript function `choice` used to demonstrate how data flow is tracked through function parameters and return values in inter-procedural analysis. It shows how the library identifies which parameters can influence the return value. ```javascript function choice(b, x, y) { return b ? x : y; } ``` -------------------------------- ### Import JavaScript Paths Library Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/Paths.qll/module This snippet shows how to import the CodeQL library for working with file system paths in JavaScript programs. ```javascript import semmle.javascript.Paths ``` -------------------------------- ### JavaScript/TypeScript CodeQL: Getting Location Information (Start) Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/frameworks/CommandLineArguments.qll/type These predicates retrieve the start column and start line of a data flow node's location. They are inherited from the Node class. ```javascript getStartColumn| Gets the start column of this data flow node. | from Node ``` ```javascript getStartLine| Gets the start line of this data flow node. | from Node ``` -------------------------------- ### Import JavaScript Module Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/Modules.qll/type Demonstrates how to import the CodeQL JavaScript library for use in analysis. ```javascript import javascript ``` -------------------------------- ### Get Start Line Number - JavaScript Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/security/dataflow/DifferentKindsComparisonBypassQuery.qll/type Retrieves the line number on which the element starts. This predicate is inherited from 'Locatable'. ```javascript getStartLine| Gets the line on which this element starts. | from Locatable ``` -------------------------------- ### Get Start Line Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/AST.qll/type Inherited from `Locatable`, this predicate returns the line number on which the `TopLevel` element starts. ```ql getStartLine()| Gets the line on which this element starts. | from Locatable ``` -------------------------------- ### Working with Socket.IO Clients in JavaScript Source: https://codeql.github.com/codeql-standard-libraries/javascript/javascript.qll/module Provides classes for working with client-side socket.io code (npm package `socket.io-client`). This library aids in analyzing how clients interact with Socket.IO servers. ```javascript const io = require('socket.io-client'); const socket = io('http://localhost:3000'); socket.on('connect', () => { console.log('Connected to server'); socket.send('Hello from client!'); }); socket.on('chat message', (msg) => { console.log('message: ' + msg); }); socket.on('disconnect', () => { console.log('Disconnected from server'); }); ``` -------------------------------- ### CodeQL Data Flow Configuration - Load/Store Steps Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/security/dataflow/TemplateObjectInjectionQuery.qll/type These experimental predicates, `isAdditionalLoadStep` and `isAdditionalLoadStoreStep`, are used to define custom data flow steps related to loading and storing data. They are marked as experimental and may change in future versions. ```javascript isAdditionalLoadStep() isAdditionalLoadStoreStep() isAdditionalLoadStoreStep() isAdditionalStoreStep() ``` -------------------------------- ### Get Start Column of Data Flow Node Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/frameworks/TrustedTypes.qll/type Retrieves the start column of a given data flow node. This helps in identifying the precise starting column of a node in a file. ```javascript getStartColumn()| Gets the start column of this data flow node. | from Node ``` -------------------------------- ### Import JavaScript/TypeScript Util Module Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/Util.qll/module Demonstrates how to import the general-purpose utility module for JavaScript and TypeScript analysis using CodeQL. ```codeql import semmle.javascript.Util ``` -------------------------------- ### Get Start Line Number (JavaScript) Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/frameworks/Templating.qll/type Retrieves the line number on which the element starts. This predicate is inherited from the `Locatable` class. ```javascript getStartLine| Gets the line on which this element starts. | from Locatable ``` -------------------------------- ### Get Start Line of a Node Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/frameworks/Restify.qll/type Returns the starting line number of a node in its source file. Crucial for locating code elements. ```javascript function getStartLine() { // Implementation details for getStartLine } ``` -------------------------------- ### JavaScript Event Handling Source: https://codeql.github.com/codeql-standard-libraries/javascript/javascript.qll/module Covers event dispatching, registration, and handling within EventEmitter instances. ```javascript EmailSender| An operation that sends an email. ``` ```javascript EventHandlerCode| A code snippet originating from an event handler attribute. ``` ```javascript EventDispatch| A dispatch of an event on an EventEmitter. ``` ```javascript EventEmitter| An EventEmitter instance that implements the EventEmitter API. Extend EventEmitter::Range to mark something as being an EventEmitter. ``` ```javascript EventRegistration| A registration of an event handler on an EventEmitter. ``` -------------------------------- ### Import JavaScript Library Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/JsonStringifiers.qll/type This snippet shows how to import the necessary JavaScript library for CodeQL analysis. ```javascript import javascript ``` -------------------------------- ### Get Start Line of Data Flow Node Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/frameworks/Handlebars.qll/type Retrieves the starting line number of a data flow node. Crucial for identifying the beginning of a code element. ```javascript getStartLine()| Gets the start line of this data flow node. | from Node ``` -------------------------------- ### Data Flow Configuration - Additional Load/Store Steps - JavaScript Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/security/dataflow/ShellCommandInjectionFromEnvironmentQuery.qll/type Experimental predicates for defining additional load and store steps in data flow analysis. These may change in future versions and are inherited from Configuration. ```javascript isAdditionalLoadStep() // EXPERIMENTAL. This API may change in the future. ``` ```javascript isAdditionalLoadStoreStep() // EXPERIMENTAL. This API may change in the future. ``` ```javascript isAdditionalStoreStep() // EXPERIMENTAL. This API may change in the future. ``` -------------------------------- ### Get Start Column of Data Flow Node Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/frameworks/Handlebars.qll/type Retrieves the starting column number of a data flow node. Essential for precise code location tracking. ```javascript getStartColumn()| Gets the start column of this data flow node. | from Node ``` -------------------------------- ### Get Start Line Number (JavaScript) Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/DefensiveProgramming.qll/type Retrieves the line number where the element starts. Useful for pinpointing code locations. ```javascript getStartLine() ``` -------------------------------- ### Import JavaScript Library Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/internal/BasicBlockInternal.qll/type This snippet shows how to import the necessary JavaScript library for CodeQL analysis. It's a common starting point for analyzing JavaScript code. ```ql import javascript ``` -------------------------------- ### Get Start Line Number (JavaScript) Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/Classes.qll/type Retrieves the line number on which an element starts. Useful for pinpointing code locations. ```javascript getStartLine| Gets the line on which this element starts. | from Locatable ``` -------------------------------- ### CodeQL Configuration Additional Flow Steps Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/security/dataflow/ServerSideUrlRedirectQuery.qll/type Experimental predicates for defining custom data flow steps. These allow specifying additional flow edges, including those with specific input and output labels, or those considered as additional load/store steps. ```javascript isAdditionalFlowStep(src, trg, inlbl, outlbl) isAdditionalFlowStep(src, trg) isAdditionalLoadStep() isAdditionalLoadStoreStep() isAdditionalStoreStep() ``` -------------------------------- ### Import xUnit Library for JavaScript/TypeScript Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/frameworks/xUnit.qll/module This snippet shows how to import the CodeQL library for working with xUnit.js tests in JavaScript and TypeScript projects. It requires the `semmle.javascript.frameworks.xUnit` module. ```javascript import semmle.javascript.frameworks.xUnit ``` -------------------------------- ### Get Start Column of Data Flow Node Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/frameworks/AsyncPackage.qll/type Retrieves the start column number of a data flow node. This complements the start line information for precise code element identification. ```javascript getStartColumn| Gets the start column of this data flow node. | from Node ``` -------------------------------- ### SuperCall Example - JavaScript/TypeScript Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/Classes.qll/type Demonstrates a basic 'super(...)' call in JavaScript or TypeScript, as represented by the SuperCall class in CodeQL. ```javascript super(...args) ``` -------------------------------- ### Get Start Column of Data Flow Node (JavaScript) Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/frameworks/StringFormatters.qll/type Retrieves the starting column number of a data flow node. This, along with the start line, precisely locates the beginning of the node in the source code. ```javascript getStartColumn| Gets the start column of this data flow node. | from Node ``` -------------------------------- ### Import SecondOrderCommandInjectionQuery Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/security/dataflow/SecondOrderCommandInjectionQuery.qll/type This snippet shows the recommended import path for class configuration, which is now part of the SecondOrderCommandInjectionQuery module. This replaces the deprecated direct import. ```javascript import semmle.javascript.security.dataflow.SecondOrderCommandInjectionQuery ``` -------------------------------- ### Get Start Column of Data Flow Node (JavaScript) Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/JsonParsers.qll/type Retrieves the starting column number of a data flow node. This, along with the start line, precisely locates the beginning of the node in the source code. ```javascript getStartColumn| Gets the start column of this data flow node. | from Node ``` -------------------------------- ### Get Start Column of Data Flow Node (JavaScript) Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/HtmlSanitizers.qll/type Retrieves the starting column number of a data flow node. This, along with the start line, precisely locates the beginning of the node in the source code. ```javascript getStartColumn| Gets the start column of this data flow node. | from Node ``` -------------------------------- ### Data Flow Configuration - Additional Load/Store Steps - JavaScript Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/security/dataflow/CleartextStorageQuery.qll/type Experimental predicates for defining additional load and store steps in data flow analysis. These may change in future versions and are inherited from Configuration. ```javascript isAdditionalLoadStep() // EXPERIMENTAL. This API may change in the future. ``` ```javascript isAdditionalLoadStoreStep() // EXPERIMENTAL. This API may change in the future. ``` ```javascript isAdditionalStoreStep() // EXPERIMENTAL. This API may change in the future. ``` -------------------------------- ### Data Flow Configuration - Additional Load/Store Steps - JavaScript Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/security/dataflow/RemotePropertyInjectionQuery.qll/type Experimental predicates for defining additional load and store steps in data flow analysis. These may change in future versions and are inherited from Configuration. ```javascript isAdditionalLoadStep() // EXPERIMENTAL. This API may change in the future. ``` ```javascript isAdditionalLoadStoreStep() // EXPERIMENTAL. This API may change in the future. ``` ```javascript isAdditionalStoreStep() // EXPERIMENTAL. This API may change in the future. ``` -------------------------------- ### Get Start Column of Data Flow Node (JavaScript) Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/Extend.qll/type Retrieves the starting column number of a data flow node. This, along with the start line, precisely locates the beginning of the node in the source code. ```javascript getStartColumn| Gets the start column of this data flow node. | from Node ``` -------------------------------- ### Get Start Node Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/AST.qll/type Inherited from `StmtContainer`, this predicate gets the unique CFG node at which execution of the `TopLevel` or function begins. ```ql getStart()| Gets the (unique) start node of the control flow graph for this toplevel or function. | from StmtContainer ``` -------------------------------- ### Data Flow Configuration - Additional Load/Store Steps - JavaScript Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/security/dataflow/RegExpInjectionQuery.qll/type Experimental predicates for defining additional load and store steps in data flow analysis. These may change in future versions and are inherited from Configuration. ```javascript isAdditionalLoadStep() // EXPERIMENTAL. This API may change in the future. ``` ```javascript isAdditionalLoadStoreStep() // EXPERIMENTAL. This API may change in the future. ``` ```javascript isAdditionalStoreStep() // EXPERIMENTAL. This API may change in the future. ``` -------------------------------- ### Working with Socket.IO Servers in JavaScript Source: https://codeql.github.com/codeql-standard-libraries/javascript/javascript.qll/module Provides classes for working with server-side socket.io code (npm package `socket.io`). This library facilitates the analysis of real-time, event-based communication. ```javascript const io = require('socket.io')(server); io.on('connection', (socket) => { console.log('a user connected'); socket.on('disconnect', () => { console.log('user disconnected'); }); socket.on('chat message', (msg) => { io.emit('chat message', msg); }); }); ``` -------------------------------- ### Get Start Line of Node Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/security/IncompleteBlacklistSanitizer.qll/type Retrieves the starting line number of a data flow node. This is fundamental for code navigation and analysis. ```javascript getStartLine| Gets the start line of this data flow node. | from Node ``` -------------------------------- ### Data Flow Configuration - Additional Load/Store Steps - JavaScript Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/security/dataflow/XmlBombQuery.qll/type Experimental predicates for defining additional load and store steps in data flow analysis. These may change in future versions and are inherited from Configuration. ```javascript isAdditionalLoadStep() // EXPERIMENTAL. This API may change in the future. ``` ```javascript isAdditionalLoadStoreStep() // EXPERIMENTAL. This API may change in the future. ``` ```javascript isAdditionalStoreStep() // EXPERIMENTAL. This API may change in the future. ``` -------------------------------- ### Get Start Column of a Node Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/frameworks/Restify.qll/type Returns the starting column number of a node in its source file. Aids in precise code location identification. ```javascript function getStartColumn() { // Implementation details for getStartColumn } ``` -------------------------------- ### Data Flow Configuration - Additional Load/Store Steps - JavaScript Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/security/dataflow/InsecureTemporaryFileQuery.qll/type Experimental predicates for defining additional load and store steps in data flow analysis. These may change in future versions and are inherited from Configuration. ```javascript isAdditionalLoadStep() // EXPERIMENTAL. This API may change in the future. ``` ```javascript isAdditionalLoadStoreStep() // EXPERIMENTAL. This API may change in the future. ``` ```javascript isAdditionalStoreStep() // EXPERIMENTAL. This API may change in the future. ``` -------------------------------- ### Get Start Line of a Node Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/frameworks/NodeJSLib.qll/type Returns the starting line number of a node in its source file. Crucial for locating code elements. ```javascript function getStartLine() { // Implementation details for getStartLine } ``` -------------------------------- ### Data Flow Configuration - Additional Load/Store Steps - JavaScript Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/security/dataflow/CommandInjectionQuery.qll/type Experimental predicates for defining additional load and store steps in data flow analysis. These may change in future versions and are inherited from Configuration. ```javascript isAdditionalLoadStep() // EXPERIMENTAL. This API may change in the future. ``` ```javascript isAdditionalLoadStoreStep() // EXPERIMENTAL. This API may change in the future. ``` ```javascript isAdditionalStoreStep() // EXPERIMENTAL. This API may change in the future. ``` -------------------------------- ### Get Start Column (JavaScript) Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/frameworks/Angular2.qll/type Retrieves the starting column of a data flow node's location in the source code. ```javascript getStartColumn() from Node ``` -------------------------------- ### Get Start Line Number (JavaScript) Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/DefUse.qll/type Retrieves the line number on which the element starts. This predicate is inherited from the `Locatable` class. ```javascript getStartLine| Gets the line on which this element starts. | from Locatable ``` -------------------------------- ### Import CleartextStorageCustomizations in JavaScript/TypeScript Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/security/dataflow/CleartextStorageCustomizations.qll/module This snippet shows how to import the CleartextStorageCustomizations module from the CodeQL standard library for JavaScript and TypeScript. This module is essential for defining and extending data flow analysis related to cleartext storage vulnerabilities. ```javascript import semmle.javascript.security.dataflow.CleartextStorageCustomizations ``` -------------------------------- ### Import JavaScript Files Library Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/Files.qll/module This snippet demonstrates how to import the CodeQL library for working with files and folders in JavaScript and TypeScript projects. It's a foundational step for analyzing file-related aspects of code. ```javascript import semmle.javascript.Files ``` -------------------------------- ### Get Start Line Number (JavaScript) Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/Closure.qll/type Retrieves the line number on which an element starts. Useful for pinpointing code locations. ```javascript getStartLine| Gets the line on which this element starts. | from Locatable ``` -------------------------------- ### CodeQL Configuration Additional Flow Steps Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/security/dataflow/UnsafeJQueryPluginQuery.qll/type Experimental predicates for defining custom data flow steps. These allow specifying additional flow edges, including those with specific input and output labels, or those considered as additional load/store steps. ```javascript isAdditionalFlowStep(src, trg, inlbl, outlbl) isAdditionalFlowStep(src, trg) isAdditionalLoadStep() isAdditionalLoadStoreStep() isAdditionalStoreStep() ``` -------------------------------- ### Get Start Line Number (JavaScript) Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/Constants.qll/type Retrieves the line number on which the element starts. This predicate is inherited from the `Locatable` class. ```javascript getStartLine| Gets the line on which this element starts. | from Locatable ``` -------------------------------- ### Import SystemCommandExecutionAsExpensiveAction Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/security/dataflow/MissingRateLimiting.qll/type This snippet shows how to import the SystemCommandExecutionAsExpensiveAction class from the CodeQL library for JavaScript/TypeScript security analysis. ```javascript import semmle.javascript.security.dataflow.MissingRateLimiting ``` -------------------------------- ### Get Start Line Number (JavaScript) Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/AMD.qll/type Retrieves the line number on which an element starts. Useful for pinpointing code locations. ```javascript getStartLine| Gets the line on which this element starts. | from Locatable ``` -------------------------------- ### Import Javascript CodeQL Library Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/frameworks/ExpressModules.qll/type This snippet shows how to import the CodeQL library for JavaScript analysis. It's a common starting point for using CodeQL with JavaScript projects. ```javascript import javascript ``` -------------------------------- ### Get Start Column of Data Flow Node (JavaScript) Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/frameworks/PropertyProjection.qll/type Retrieves the starting column number of a data flow node. This, along with the start line, precisely locates the beginning of the node in the source code. ```javascript getStartColumn| Gets the start column of this data flow node. | from Node ``` -------------------------------- ### Import CodeQL JavaScript Standard Library Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/StandardLibrary.qll/module This snippet shows how to import the CodeQL standard library for JavaScript and TypeScript. It provides access to classes for analyzing JavaScript programs and standard library objects. ```javascript import semmle.javascript.StandardLibrary ``` -------------------------------- ### Get Start Column of Data Flow Node Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/frameworks/Knex.qll/type Retrieves the starting column number of a data flow node. This, along with the start line, precisely locates the node's beginning in the source code. ```javascript getStartColumn() ``` -------------------------------- ### Get Start Column of Data Flow Node (JavaScript) Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/frameworks/ComposedFunctions.qll/type Retrieves the starting column number of a data flow node. This, along with the start line, precisely locates the beginning of the node in the source code. ```javascript getStartColumn| Gets the start column of this data flow node. | from Node ``` -------------------------------- ### Data Flow Configuration - Additional Load/Store Steps - JavaScript Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/security/dataflow/HttpToFileAccessQuery.qll/type Experimental predicates for defining additional load and store steps in data flow analysis. These may change in future versions and are inherited from Configuration. ```javascript isAdditionalLoadStep() // EXPERIMENTAL. This API may change in the future. ``` ```javascript isAdditionalLoadStoreStep() // EXPERIMENTAL. This API may change in the future. ``` ```javascript isAdditionalStoreStep() // EXPERIMENTAL. This API may change in the future. ``` -------------------------------- ### Data Flow Configuration - Additional Load/Store Steps - JavaScript Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/security/dataflow/XpathInjectionQuery.qll/type Experimental predicates for defining additional load and store steps in data flow analysis. These may change in future versions and are inherited from Configuration. ```javascript isAdditionalLoadStep() // EXPERIMENTAL. This API may change in the future. ``` ```javascript isAdditionalLoadStoreStep() // EXPERIMENTAL. This API may change in the future. ``` ```javascript isAdditionalStoreStep() // EXPERIMENTAL. This API may change in the future. ``` -------------------------------- ### Get Start Column of Data Flow Node (JavaScript) Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/JsonSchema.qll/type Retrieves the starting column number of a data flow node. This, along with the start line, precisely locates the beginning of the node in the source code. ```javascript getStartColumn| Gets the start column of this data flow node. | from Node ``` -------------------------------- ### JavaScript/TypeScript TopLevel Example Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/AST.qll/type This snippet demonstrates a basic JavaScript code block within an HTML script tag, which is recognized as a `TopLevel` syntactic unit by CodeQL. ```html ``` -------------------------------- ### Get Start Column of a Node Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/frameworks/NodeJSLib.qll/type Returns the starting column number of a node in its source file. Aids in precise code location identification. ```javascript function getStartColumn() { // Implementation details for getStartColumn } ``` -------------------------------- ### Get Start Line (JavaScript) Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/frameworks/Angular2.qll/type Retrieves the starting line number of a data flow node's location in the source code. ```javascript getStartLine() from Node ``` -------------------------------- ### Data Flow Configuration - Additional Load/Store Steps - JavaScript Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/security/dataflow/StackTraceExposureQuery.qll/type Experimental predicates for defining additional load and store steps in data flow analysis. These may change in future versions and are inherited from Configuration. ```javascript isAdditionalLoadStep() // EXPERIMENTAL. This API may change in the future. ``` ```javascript isAdditionalLoadStoreStep() // EXPERIMENTAL. This API may change in the future. ``` ```javascript isAdditionalStoreStep() // EXPERIMENTAL. This API may change in the future. ``` -------------------------------- ### JavaScript/TypeScript Endpoint Naming Example Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/endpoints/EndpointNaming.qll/module Demonstrates how classes and functions can be exposed to client code without being accessible as qualified names, requiring the library to generate human-readable names for these endpoints. ```javascript // 'Foo' is internal, but clients can call its methods, e.g. `getFoo().m()` class Foo { m() {} } export function getFoo() { return new Foo(); } // Clients can call m() via getObj().m() export function getObj() { return { m() {} } } ``` -------------------------------- ### Get Start Location Line (JavaScript) Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/dataflow/internal/PropertyTypeInference.qll/type Retrieves the starting line number of a data flow node. Crucial for pinpointing code origins. ```javascript getStartLine(): integer Gets the start line of this data flow node. ``` -------------------------------- ### Get Start Location Column (JavaScript) Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/dataflow/internal/PropertyTypeInference.qll/type Retrieves the starting column number of a data flow node. Essential for precise code referencing. ```javascript getStartColumn(): integer Gets the start column of this data flow node. ``` -------------------------------- ### Data Flow Configuration - Additional Load/Store Steps - JavaScript Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/security/dataflow/XxeQuery.qll/type Experimental predicates for defining additional load and store steps in data flow analysis. These may change in future versions and are inherited from Configuration. ```javascript isAdditionalLoadStep() // EXPERIMENTAL. This API may change in the future. ``` ```javascript isAdditionalLoadStoreStep() // EXPERIMENTAL. This API may change in the future. ``` ```javascript isAdditionalStoreStep() // EXPERIMENTAL. This API may change in the future. ``` -------------------------------- ### Import Javascript Library for CodeQL Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/frameworks/PropertyProjection.qll/type This snippet shows the import path for the CodeQL JavaScript library, which is necessary for using its features and classes. ```javascript import javascript ``` -------------------------------- ### Get Start and End Line Numbers Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/ES2015Modules.qll/type Retrieves the starting and ending line numbers for a locatable element. Essential for pinpointing code locations. ```javascript getEndLine()| Gets the line on which this element ends. | from Locatable ``` ```javascript getStartLine()| Gets the line on which this element starts. | from Locatable ``` -------------------------------- ### JavaScript Authorization and Await Expressions Source: https://codeql.github.com/codeql-standard-libraries/javascript/javascript.qll/module Covers authorization-related calls and the 'await' expression syntax in JavaScript. ```javascript AuthorizationCall AwaitExpr ``` -------------------------------- ### Get Start Line Number (JavaScript) Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/E4X.qll/type Retrieves the line number on which the current element starts. This predicate is part of the 'Locatable' class. ```javascript getStartLine() ``` -------------------------------- ### Get Start Line in JavaScript Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/frameworks/Testing.qll/type Retrieves the starting line number of a code element. Useful for pinpointing the location of code constructs in the source file. ```javascript getStartLine| Gets the line on which this element starts. | from Locatable ``` -------------------------------- ### JavaScript ES Modules and Components Source: https://codeql.github.com/codeql-standard-libraries/javascript/javascript.qll/module Details different ways of defining and structuring JavaScript code using ES2015 modules and React components. ```javascript ES2015Component| A React component implemented as a class ``` ```javascript ES2015Module| An ECMAScript 2015 module. ``` ```javascript ES5Component| A legacy React component implemented using `React.createClass` or `create-react-class`. ``` -------------------------------- ### Data Flow Configuration - Additional Load/Store Steps - JavaScript Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/security/dataflow/UnsafeDeserializationQuery.qll/type Experimental predicates for defining additional load and store steps in data flow analysis. These may change in future versions and are inherited from Configuration. ```javascript isAdditionalLoadStep() // EXPERIMENTAL. This API may change in the future. ``` ```javascript isAdditionalLoadStoreStep() // EXPERIMENTAL. This API may change in the future. ``` ```javascript isAdditionalStoreStep() // EXPERIMENTAL. This API may change in the future. ``` -------------------------------- ### Get Start Line of Node Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/frameworks/ShellJS.qll/type Retrieves the start line number of a data flow node. This is fundamental for code navigation and error reporting. ```javascript getStartLine| Gets the start line of this data flow node. | from Node ``` -------------------------------- ### Import ZipSlipCustomizations in JavaScript/TypeScript Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/security/dataflow/ZipSlipCustomizations.qll/module This snippet shows how to import the ZipSlipCustomizations module from the CodeQL standard library for JavaScript and TypeScript. This module provides classes and predicates for analyzing ZipSlip vulnerabilities. ```javascript import semmle.javascript.security.dataflow.ZipSlipCustomizations ``` -------------------------------- ### Get Start Column of Node Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/frameworks/ShellJS.qll/type Retrieves the start column number of a data flow node. This helps in precise code location analysis. ```javascript getStartColumn| Gets the start column of this data flow node. | from Node ``` -------------------------------- ### Get Start Column of Data Flow Node Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/StandardLibrary.qll/type Retrieves the start column of a data flow node. Helps in identifying the beginning of a code element. ```javascript getStartColumn| Gets the start column of this data flow node. | from Node ``` -------------------------------- ### Import DeepObjectResourceExhaustionCustomizations in JavaScript/TypeScript Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/security/dataflow/DeepObjectResourceExhaustionCustomizations.qll/module This snippet shows how to import the `DeepObjectResourceExhaustionCustomizations` module from the CodeQL standard library for JavaScript and TypeScript. This module is essential for analyzing DoS vulnerabilities related to object handling. ```javascript import semmle.javascript.security.dataflow.DeepObjectResourceExhaustionCustomizations ``` -------------------------------- ### Import JavaScript CodeQL Library Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/frameworks/DigitalOcean.qll/type This snippet shows how to import the CodeQL library for JavaScript and TypeScript, specifically version 2.6.10-dev, which includes the DigitalOcean::Credentials class. ```javascript import javascript ``` -------------------------------- ### Get Start Line of Data Flow Node Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/Promises.qll/type Retrieves the starting line number of a data flow node. This is fundamental for code navigation and analysis. ```javascript getStartLine() | Gets the start line of this data flow node. | from Node ``` -------------------------------- ### Import JavaScript Tokens Module Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/Tokens.qll/module This snippet shows how to import the CodeQL module for JavaScript tokens. This module provides classes for working with the token-based representation of JavaScript programs. ```javascript import semmle.javascript.Tokens ``` -------------------------------- ### Get Start Line of Data Flow Node Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/security/UselessUseOfCat.qll/type Retrieves the start line number of a data flow node. Used for pinpointing the beginning of a code element. ```javascript getStartLine| Gets the start line of this data flow node. | from Node ``` -------------------------------- ### Import CleartextLoggingCustomizations in JavaScript Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/security/dataflow/CleartextLoggingCustomizations.qll/module This snippet shows how to import the CleartextLoggingCustomizations module from the CodeQL standard library for JavaScript. This module is used for reasoning about clear-text logging of sensitive information. ```javascript import semmle.javascript.security.dataflow.CleartextLoggingCustomizations ``` -------------------------------- ### Get Start Column of Data Flow Node Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/security/UselessUseOfCat.qll/type Retrieves the start column number of a data flow node. Essential for precise code location analysis. ```javascript getStartColumn| Gets the start column of this data flow node. | from Node ``` -------------------------------- ### JavaScript Function Preamble CFG Example Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/CFG.qll/module Illustrates the Control Flow Graph (CFG) for a JavaScript function declaration, showing the entry node, preamble (including parameters and hoisted functions), body, and exit node. ```javascript function outer(x, y = 42) { s function inner() {} t } ``` ```text [entry] → [x] → [42] → [y] → [inner] → [s] → [function inner() {}] → [t] → [exit] ``` -------------------------------- ### Get Start Column of Node Source: https://codeql.github.com/codeql-standard-libraries/javascript/semmle/javascript/security/IncompleteBlacklistSanitizer.qll/type Retrieves the starting column number of a data flow node within its source line. This aids in precise code location. ```javascript getStartColumn| Gets the start column of this data flow node. | from Node ```