Skip to content

Commit

Permalink
feat: POC LogicalLocations
Browse files Browse the repository at this point in the history
  • Loading branch information
devtooligan committed Apr 3, 2024
1 parent d6642be commit 2701258
Show file tree
Hide file tree
Showing 10 changed files with 592 additions and 117 deletions.
29 changes: 19 additions & 10 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
// Place your settings in this file to overwrite default and user settings.

Check failure on line 1 in .vscode/settings.json

View workflow job for this annotation

GitHub Actions / Trunk Check

prettier

Incorrect formatting, autoformat by running 'trunk fmt'

{
"files.exclude": {
"out": false, // set this to true to hide the "out" folder with the compiled JS files
"dist": false // set this to true to hide the "dist" folder with the compiled JS files
"workbench.colorCustomizations": {
"titleBar.activeForeground": "#860303",
"titleBar.inactiveForeground": "#860303",
"titleBar.activeBackground": "#ffc8c8",
"titleBar.inactiveBackground": "#ffc8c8"
},
"search.exclude": {
"out": true, // set this to false to include "out" folder in search results
"dist": true // set this to false to include "dist" folder in search results
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off"
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": [
"comment",
],
"settings": {
"fontStyle": "",
}
}
]
}
}
2 changes: 2 additions & 0 deletions src/extension/sarifExplorerWebview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export class SarifExplorerWebview {
private WORKSPACE_STORAGE_IS_VISIBLE_KEY = "isVisible";

constructor(context: vscode.ExtensionContext) {
// vscode show message "hola amigo"
vscode.window.showInformationMessage("hola amigo");
this._context = context;

this.loadWorkspaceSarifFiles();
Expand Down
8 changes: 8 additions & 0 deletions src/shared/resultTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export type LabeledLocation = {
export type ResultLocation = {
path: string;
region: ResultRegion;
logicalLocations?: any[];

Check warning on line 34 in src/shared/resultTypes.ts

View workflow job for this annotation

GitHub Actions / Trunk Check

eslint(@typescript-eslint/no-explicit-any)

[new] Unexpected any. Specify a different type.
};

export type ResultRegion = {
Expand All @@ -40,6 +41,13 @@ export type ResultRegion = {
endColumn: number;
};

export type LogicalLocationNode = {
[key: string]: any;

Check warning on line 45 in src/shared/resultTypes.ts

View workflow job for this annotation

GitHub Actions / Trunk Check

eslint(@typescript-eslint/no-explicit-any)

[new] Unexpected any. Specify a different type.
results?: any[];

Check warning on line 46 in src/shared/resultTypes.ts

View workflow job for this annotation

GitHub Actions / Trunk Check

eslint(@typescript-eslint/no-explicit-any)

[new] Unexpected any. Specify a different type.
name?: string;
index?: number; // Added index property
};

/* eslint-disable @typescript-eslint/naming-convention */
export enum ResultStatus {
Todo = 0,
Expand Down
9 changes: 9 additions & 0 deletions src/test/sarif_files/a.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
pragma solidity 0.8.19;

error RevertIt();

contract Example {
function reverts() external pure {
revert RevertIt();
}
}
9 changes: 9 additions & 0 deletions src/test/sarif_files/b.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
pragma solidity 0.8.19;

error RevertIt();

contract Example {
function reverts() external pure {
revert RevertIt();
}
}
9 changes: 9 additions & 0 deletions src/test/sarif_files/c.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
pragma solidity 0.8.19;

error RevertIt();

contract Example {
function reverts() external pure {
revert RevertIt();
}
}
160 changes: 160 additions & 0 deletions src/test/sarif_files/logicallocations.sarif
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
{
"$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
"version": "2.1.0",
"runs": [
{
"tool": {
"driver": {
"name": "Slither",
"informationUri": "https://github.com/crytic/slither",
"version": "0.10.0",
"rules": []
}
},
"logicalLocations": [
{
"name": "MyContract",
"kind": "contract",
"parentIndex": -1
},
{
"name": "myFunction",
"kind": "function",
"parentIndex": 0
}
],
"results": [
{
"ruleId": "Project",
"message": {
"text": "Check all dependencies for most recent version",
"markdown": "MARKDOWN Check all dependencies for most recent version"
},
"level": "note",
"locations": [
{
"physicalLocation": {
"artifactLocation": {
"uri": "/Users/devtooligan/audit/tools/tob-extensions/vscode-sarif-explorer/src/test/sarif_files/a.sol"
}
},
"logicalLocations": [
{
"index": 1
}]
},
{
"physicalLocation": {
"artifactLocation": {
"uri": "/Users/devtooligan/audit/tools/tob-extensions/vscode-sarif-explorer/src/test/sarif_files/b.sol"
}
},
"logicalLocations": [
{
"index": 1
}]
},
{
"physicalLocation": {
"artifactLocation": {
"uri": "/Users/devtooligan/audit/tools/tob-extensions/vscode-sarif-explorer/src/test/sarif_files/b.sol"
},
"logicalLocations": [
{
"index": 1
}]
}
}
],
"partialFingerprints": {
"id": "9b6c59ba8db955b843fd53b0e479463ef0abdc939ce0e83a194e8e556b9f2f29"
}
},
{
"ruleId": "hoagies",
"message": {
"text": "Pragma version0.8.19 (/Users/devtooligan/audit/tools/tob-extensions/vscode-sarif-explorer/src/test/sarif_files/a.sol#1) necessitates a version too recent to be trusted. Consider deploying with 0.8.18.\n",
"markdown": "Pragma version[0.8.19](/Users/devtooligan/audit/tools/tob-extensions/vscode-sarif-explorer/src/test/sarif_files/a.sol#L1) necessitates a version too recent to be trusted. Consider deploying with 0.8.18.\n"
},
"level": "warning",
"locations": [
{
"physicalLocation": {
"artifactLocation": {
"uri": "/Users/devtooligan/audit/tools/tob-extensions/vscode-sarif-explorer/src/test/sarif_files/a.sol"
},
"region": {
"startLine": 1,
"endLine": 1
}
},
"logicalLocations": [
{
"index": 1
}]
}
],
"partialFingerprints": {
"id": "9b6c59ba8db955b843fd53b0e479463ef0abdc939ce0e83a194e8e556b9f2f29"
}
},
{
"ruleId": "hoagies2",
"message": {
"text": "Pragma version0.8.19 (/Users/devtooligan/audit/tools/tob-extensions/vscode-sarif-explorer/src/test/sarif_files/a.sol#1) necessitates a version too recent to be trusted. Consider deploying with 0.8.18.\n",
"markdown": "Pragma version[0.8.19](/Users/devtooligan/audit/tools/tob-extensions/vscode-sarif-explorer/src/test/sarif_files/a.sol#L1) necessitates a version too recent to be trusted. Consider deploying with 0.8.18.\n"
},
"level": "warning",
"locations": [
{
"physicalLocation": {
"artifactLocation": {
"uri": "/Users/devtooligan/audit/tools/tob-extensions/vscode-sarif-explorer/src/test/sarif_files/a.sol"
},
"region": {
"startLine": 1,
"endLine": 1
}
},
"logicalLocations": [
{
"index": 1
}]
}
],
"partialFingerprints": {
"id": "9b6c59ba8db955b843fd53b0e479463ef0abdc939ce0e83a194e8e556b9f2f29"
}
},
{
"ruleId": "hoagies3",
"message": {
"text": "Pragma version0.8.19 (/Users/devtooligan/audit/tools/tob-extensions/vscode-sarif-explorer/src/test/sarif_files/a.sol#1) necessitates a version too recent to be trusted. Consider deploying with 0.8.18.\n",
"markdown": "Pragma version[0.8.19](/Users/devtooligan/audit/tools/tob-extensions/vscode-sarif-explorer/src/test/sarif_files/a.sol#L1) necessitates a version too recent to be trusted. Consider deploying with 0.8.18.\n"
},
"level": "warning",
"locations": [
{
"physicalLocation": {
"artifactLocation": {
"uri": "/Users/devtooligan/audit/tools/tob-extensions/vscode-sarif-explorer/src/test/sarif_files/a.sol"
},
"region": {
"startLine": 1,
"endLine": 1
}
},
"logicalLocations": [
{
"index": 1
}]
}
],
"partialFingerprints": {
"id": "9b6c59ba8db955b843fd53b0e479463ef0abdc939ce0e83a194e8e556b9f2f29"
}
}
]
}
]
}
2 changes: 2 additions & 0 deletions src/webviewSrc/result/resultsTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type SortConfig = {
};

export class ResultsTable {
private logicalLocations: any = {};

Check warning on line 36 in src/webviewSrc/result/resultsTable.ts

View workflow job for this annotation

GitHub Actions / Trunk Check

eslint(@typescript-eslint/no-explicit-any)

[new] Unexpected any. Specify a different type.
private results: Result[] = [];
private sortConfig: SortConfig = {
unchangeableSortHeader: TableHeaders.RuleID,
Expand All @@ -56,6 +57,7 @@ export class ResultsTable {
return this.results.filter((result) => this.filters.filter(result));
}

// Returns the results in the table without the ones which are filtered and sorted by
public isResultFiltered(result: Result): boolean {
return !this.filters.filter(result);
}
Expand Down
Loading

0 comments on commit 2701258

Please sign in to comment.