mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Merge branch 'main' into henrymercer/rc-3.11-mergeback
This commit is contained in:
@@ -11,11 +11,15 @@ signature module InputSig {
|
||||
/**
|
||||
* Gets the absolute path of this container.
|
||||
*
|
||||
* Typically `containerparent(result, this)`.
|
||||
* Typically `folders(this, result) or files(this, result)`.
|
||||
*/
|
||||
string getAbsolutePath();
|
||||
|
||||
/** Gets the parent container of this container, if any. */
|
||||
/**
|
||||
* Gets the parent container of this container, if any.
|
||||
*
|
||||
* Typically `containerparent(result, this)`.
|
||||
*/
|
||||
ContainerBase getParentContainer();
|
||||
}
|
||||
|
||||
@@ -80,6 +84,17 @@ module Make<InputSig Input> {
|
||||
*/
|
||||
string getAbsolutePath() { result = super.getAbsolutePath() }
|
||||
|
||||
/**
|
||||
* Holds if either,
|
||||
* - `part` is the base name of this container and `i = 1`, or
|
||||
* - `part` is the stem of this container and `i = 2`, or
|
||||
* - `part` is the extension of this container and `i = 3`.
|
||||
*/
|
||||
cached
|
||||
private predicate splitAbsolutePath(string part, int i) {
|
||||
part = this.getAbsolutePath().regexpCapture(".*/(([^/]*?)(?:\\.([^.]*))?)", i)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the base name of this container including extension, that is, the last
|
||||
* segment of its absolute path, or the empty string if it has no segments.
|
||||
@@ -97,9 +112,7 @@ module Make<InputSig Input> {
|
||||
* <tr><td>"//FileServer/"</td><td>""</td></tr>
|
||||
* </table>
|
||||
*/
|
||||
string getBaseName() {
|
||||
result = this.getAbsolutePath().regexpCapture(".*/(([^/]*?)(?:\\.([^.]*))?)", 1)
|
||||
}
|
||||
string getBaseName() { this.splitAbsolutePath(result, 1) }
|
||||
|
||||
/**
|
||||
* Gets the extension of this container, that is, the suffix of its base name
|
||||
@@ -124,9 +137,7 @@ module Make<InputSig Input> {
|
||||
* <tr><td>"/tmp/x.tar.gz"</td><td>"gz"</td></tr>
|
||||
* </table>
|
||||
*/
|
||||
string getExtension() {
|
||||
result = this.getAbsolutePath().regexpCapture(".*/([^/]*?)(\\.([^.]*))?", 3)
|
||||
}
|
||||
string getExtension() { this.splitAbsolutePath(result, 3) }
|
||||
|
||||
/** Gets the file in this container that has the given `baseName`, if any. */
|
||||
File getFile(string baseName) {
|
||||
@@ -179,9 +190,7 @@ module Make<InputSig Input> {
|
||||
* <tr><td>"/tmp/x.tar.gz"</td><td>"x.tar"</td></tr>
|
||||
* </table>
|
||||
*/
|
||||
string getStem() {
|
||||
result = this.getAbsolutePath().regexpCapture(".*/([^/]*?)(?:\\.([^.]*))?", 1)
|
||||
}
|
||||
string getStem() { this.splitAbsolutePath(result, 2) }
|
||||
|
||||
/**
|
||||
* Gets a URL representing the location of this container.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
private newtype TUnit = TMkUnit()
|
||||
|
||||
/** The trivial type with a single element. */
|
||||
class Unit extends TUnit {
|
||||
final class Unit extends TUnit {
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() { result = "unit" }
|
||||
}
|
||||
|
||||
@@ -5,12 +5,23 @@ signature class AstNode {
|
||||
}
|
||||
|
||||
signature class SingleLineComment {
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString();
|
||||
|
||||
/**
|
||||
* Holds if this element is at the specified location.
|
||||
* The location spans column `startcolumn` of line `startline` to
|
||||
* column `endcolumn` of line `endline` in file `filepath`.
|
||||
* For more information, see
|
||||
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
|
||||
*/
|
||||
predicate hasLocationInfo(
|
||||
string filepath, int startline, int startcolumn, int endline, int endcolumn
|
||||
);
|
||||
|
||||
/**
|
||||
* Gets the text of this suppression comment.
|
||||
*/
|
||||
string getText();
|
||||
}
|
||||
|
||||
@@ -18,28 +29,12 @@ signature class SingleLineComment {
|
||||
* Constructs an alert suppression query.
|
||||
*/
|
||||
module Make<AstNode Node, SingleLineComment Comment> {
|
||||
final private class FinalCommnent = Comment;
|
||||
|
||||
/**
|
||||
* An alert suppression comment.
|
||||
*/
|
||||
abstract class SuppressionComment instanceof Comment {
|
||||
/**
|
||||
* Gets the text of this suppression comment.
|
||||
*/
|
||||
string getText() { result = super.getText() }
|
||||
|
||||
/**
|
||||
* Holds if this element is at the specified location.
|
||||
* The location spans column `startcolumn` of line `startline` to
|
||||
* column `endcolumn` of line `endline` in file `filepath`.
|
||||
* For more information, see
|
||||
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
|
||||
*/
|
||||
predicate hasLocationInfo(
|
||||
string filepath, int startline, int startcolumn, int endline, int endcolumn
|
||||
) {
|
||||
super.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
|
||||
}
|
||||
|
||||
abstract class SuppressionComment extends FinalCommnent {
|
||||
/** Gets the suppression annotation in this comment. */
|
||||
abstract string getAnnotation();
|
||||
|
||||
@@ -53,9 +48,6 @@ module Make<AstNode Node, SingleLineComment Comment> {
|
||||
|
||||
/** Gets the scope of this suppression. */
|
||||
SuppressionScope getScope() { this = result.getSuppressionComment() }
|
||||
|
||||
/** Gets a textual representation of this element. */
|
||||
string toString() { result = super.toString() }
|
||||
}
|
||||
|
||||
private class LgtmSuppressionComment extends SuppressionComment {
|
||||
|
||||
Reference in New Issue
Block a user