Skip to content

Commit

Permalink
added missing libs
Browse files Browse the repository at this point in the history
  • Loading branch information
faculerena committed Oct 17, 2024
1 parent 8123952 commit 6c22f16
Show file tree
Hide file tree
Showing 147 changed files with 31,760 additions and 161 deletions.
1 change: 1 addition & 0 deletions solidity/codeql/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Cargo.lock -diff -whitespace
13 changes: 7 additions & 6 deletions solidity/codeql/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
solidity-test/../log/
codeql/
target/
*.log
solidity-test/dbs/
.vscode
extractor/target
.vscode/launch.json
.cache
ql/test/**/*.testproj
ql/test/**/*.actual
ql/test/**/CONSISTENCY
.codeql
78 changes: 62 additions & 16 deletions solidity/codeql/Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,68 @@
CODEQL_COMMIT = 123c375d844b9c2fd9ffcb4315a3f50c6b56f5ae
CODEQL_PATH = codeql
all: extractor dbscheme

install-for-vscode:
cd $(CODEQL_PATH)/solidity/ql/lib && codeql pack install
ifeq ($(OS),Windows_NT)
EXE = .exe
CODEQL_PLATFORM = win64
else
EXE =
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
CODEQL_PLATFORM = linux64
endif
ifeq ($(UNAME_S),Darwin)
CODEQL_PLATFORM = osx64
endif
endif

clone-codeql:
if [ ! -d "$(CODEQL_PATH)" ]; then \
git clone https://github.com/github/codeql.git; \
fi
cd $(CODEQL_PATH) && git checkout $(CODEQL_COMMIT)
FILES=codeql-extractor.yml\
tools/qltest.cmd\
tools/index-files.sh\
tools/index-files.cmd\
tools/autobuild.sh\
tools/qltest.sh\
tools/autobuild.cmd\
ql/lib/solidity.dbscheme.stats\
ql/lib/solidity.dbscheme

copy-solidity: clone-codeql
cp -r solidity $(CODEQL_PATH)
BIN_FILES=target/release/codeql-extractor-solidity$(EXE)

build-extractor: copy-solidity
cd $(CODEQL_PATH)/solidity && make extractor
extractor-common:
rm -rf build
mkdir build
mkdir build/codeql-extractor-solidity
cp codeql-extractor.yml ql/lib/solidity.dbscheme ql/lib/solidity.dbscheme.stats build/codeql-extractor-solidity
cp -r tools build/codeql-extractor-solidity/

create-dbs: build-extractor
cd solidity-test && ./create-dbs.sh
.PHONY: tools
tools: $(BIN_FILES)
rm -rf tools/bin
mkdir tools/bin
cp -r target/release/codeql-extractor-solidity$(EXE) tools/bin/extractor$(EXE)

full-install: build-extractor create-dbs install-for-vscode
target/release/%$(EXE):
cd extractor && cargo build --release

dbscheme:
cd extractor && cargo build --release
extractor/target/release/codeql-extractor-solidity generate --dbscheme ql/lib/solidity.dbscheme --library ql/lib/codeql/solidity/ast/internal/TreeSitter.qll
codeql query format -i ql/lib/codeql/solidity/ast/internal/TreeSitter.qll

.PHONY: extractor
extractor: $(FILES) $(BIN_FILES)
rm -rf extractor-pack
mkdir extractor-pack
mkdir extractor-pack/tools
mkdir extractor-pack/tools/$(CODEQL_PLATFORM)
cp codeql-extractor.yml extractor-pack/codeql-extractor.yml
cp tools/qltest.cmd extractor-pack/tools/qltest.cmd
cp tools/index-files.sh extractor-pack/tools/index-files.sh
cp tools/index-files.cmd extractor-pack/tools/index-files.cmd
cp tools/autobuild.sh extractor-pack/tools/autobuild.sh
cp tools/qltest.sh extractor-pack/tools/qltest.sh
cp tools/autobuild.cmd extractor-pack/tools/autobuild.cmd
cp ql/lib/solidity.dbscheme.stats extractor-pack/solidity.dbscheme.stats
cp ql/lib/solidity.dbscheme extractor-pack/solidity.dbscheme
cp extractor/target/release/codeql-extractor-solidity$(EXE) extractor-pack/tools/$(CODEQL_PLATFORM)/extractor$(EXE)

test: extractor dbscheme
codeql test run --check-databases --check-unused-labels --check-repeated-labels --check-redefined-labels --check-use-before-definition --search-path .. --consistency-queries ql/consistency-queries ql/test
127 changes: 0 additions & 127 deletions solidity/codeql/README.md

This file was deleted.

11 changes: 0 additions & 11 deletions solidity/codeql/extractor-pack/tools/BUILD.bazel

This file was deleted.

Binary file modified solidity/codeql/extractor-pack/tools/linux64/extractor
Binary file not shown.
2 changes: 1 addition & 1 deletion solidity/codeql/extractor/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file removed solidity/codeql/images/image1.png
Binary file not shown.
16 changes: 16 additions & 0 deletions solidity/codeql/ql/lib/codeql/IDEContextual.qll
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Provides shared predicates related to contextual queries in the code viewer.
*/

private import codeql.files.FileSystem
private import codeql.util.FileSystem

/**
* Returns an appropriately encoded version of a filename `name`
* passed by the VS Code extension in order to coincide with the
* output of `.getFile()` on locatable entities.
*/
cached
File getFileBySourceArchiveName(string name) {
result = IdeContextual<File>::getFileBySourceArchiveName(name)
}
68 changes: 68 additions & 0 deletions solidity/codeql/ql/lib/codeql/Locations.qll
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/** Provides classes for working with locations. */

import files.FileSystem

/**
* A location as given by a file, a start line, a start column,
* an end line, and an end column.
*
* For more information about locations see [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
*/
class Location extends @location_default {
/** Gets the file for this location. */
File getFile() { locations_default(this, result, _, _, _, _) }

/** Gets the 1-based line number (inclusive) where this location starts. */
int getStartLine() { locations_default(this, _, result, _, _, _) }

/** Gets the 1-based column number (inclusive) where this location starts. */
int getStartColumn() { locations_default(this, _, _, result, _, _) }

/** Gets the 1-based line number (inclusive) where this location ends. */
int getEndLine() { locations_default(this, _, _, _, result, _) }

/** Gets the 1-based column number (inclusive) where this location ends. */
int getEndColumn() { locations_default(this, _, _, _, _, result) }

/** Gets the number of lines covered by this location. */
int getNumLines() { result = this.getEndLine() - this.getStartLine() + 1 }

/** Gets a textual representation of this element. */
bindingset[this]
pragma[inline_late]
string toString() {
exists(string filepath, int startline, int startcolumn, int endline, int endcolumn |
this.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) and
result = filepath + "@" + startline + ":" + startcolumn + ":" + endline + ":" + endcolumn
)
}

/**
* 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
* [Providing locations in CodeQL queries](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
) {
exists(File f |
locations_default(this, f, startline, startcolumn, endline, endcolumn) and
filepath = f.getAbsolutePath()
)
}

/** Holds if this location starts strictly before the specified location. */
pragma[inline]
predicate strictlyBefore(Location other) {
this.getStartLine() < other.getStartLine()
or
this.getStartLine() = other.getStartLine() and this.getStartColumn() < other.getStartColumn()
}
}

/** An entity representing an empty location. */
class EmptyLocation extends Location {
EmptyLocation() { empty_location(this) }
}
36 changes: 36 additions & 0 deletions solidity/codeql/ql/lib/codeql/files/FileSystem.qll
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/** Provides classes for working with files and folders. */

private import codeql.Locations
private import codeql.util.FileSystem

private module Input implements InputSig {
abstract class ContainerBase extends @container {
abstract string getAbsolutePath();

ContainerBase getParentContainer() { containerparent(result, this) }

string toString() { result = this.getAbsolutePath() }
}

class FolderBase extends ContainerBase, @folder {
override string getAbsolutePath() { folders(this, result) }
}

class FileBase extends ContainerBase, @file {
override string getAbsolutePath() { files(this, result) }
}

predicate hasSourceLocationPrefix = sourceLocationPrefix/1;
}

private module Impl = Make<Input>;

class Container = Impl::Container;

class Folder = Impl::Folder;

/** A file. */
class File extends Container, Impl::File {
/** Holds if this file was extracted from ordinary source code. */
predicate fromSource() { any() }
}
Loading

0 comments on commit 6c22f16

Please sign in to comment.