Skip to content

Commit

Permalink
feat(ci): Add cspell
Browse files Browse the repository at this point in the history
  • Loading branch information
byakuren-hijiri committed Jul 26, 2024
1 parent 82b03c4 commit db3517a
Show file tree
Hide file tree
Showing 16 changed files with 778 additions and 37 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ jobs:
sudo apt update
sudo apt install souffle
- name: Spellcheck code base
run: |
yarn spell
- name: Check formatting with Prettier
run: yarn fmt

Expand Down
101 changes: 101 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
"version": "0.2",
"language": "en",
"words": [
"alnum",
"assgn",
"augmentedassign",
"binop",
"blockstore",
"bounceable",
"codegen",
"decompile",
"Decompiled",
"decompiler",
"decompiles",
"decompilation",
"decompiling",
"Descr",
"disasm",
"divmod",
"dnsresolve",
"elseifnot",
"Fift",
"forall",
"funs",
"funcfiftlib",
"idict",
"initof",
"infixl",
"infixr",
"ipfs",
"ipld",
"jettons",
"jsxdev",
"langle",
"lparen",
"lvalue",
"masterchain",
"maxint",
"minmax",
"mintable",
"multiformats",
"Korshakov",
"nocheck",
"noexcept",
"Nonterminal",
"nonterminal",
"Neovim",
"Offchain",
"Parens",
"POSIX",
"prando",
"rangle",
"rparen",
"rugpull",
"rugpulled",
"sctx",
"seqno",
"shiki",
"Stateinit",
"stdlib",
"struct",
"structs",
"subtyping",
"testdata",
"Topup",
"typechecker",
"udict",
"uintptr",
"uncons",
"uninit",
"unixfs",
"workchain",
"worklist",
"powerset",
"semilattice",
"fixpoint",
"graphviz",
"idxs",
"unmarshalled",
"fixpoints",
"Datalog",
"lvalues",
"callees",
"intraprocedural",
"subdirs",
"привет",
"PUSHREF",
"PUSHSLICE",
"SETINDEXVARQ"
],
"flagWords": [],
"ignorePaths": [
"tags",
"*.fif",
"node_modules",
"dist"
]
}

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.1",
"repository": "https://github.com/nowarp/misti/",
"homepage": "https://nowarp.github.io/misti/",
"description": "TON Static Analyser",
"description": "TON Static Analyzer",
"author": "",
"license": "Apache-2.0",
"scripts": {
Expand All @@ -12,6 +12,7 @@
"test": "tsc && jest",
"lint": "eslint src test examples",
"fmt": "prettier --check src test examples",
"spell": "cspell \"**\" --no-progress --exclude \"dist/**\" --exclude \"node_modules/**\" --exclude \"tags/**\"",
"docs": "yarn typedoc --out docs/api --entryPointStrategy expand src",
"misti": "ts-node src/main.ts"
},
Expand Down Expand Up @@ -40,6 +41,7 @@
"@types/qs": "^6.9.7",
"@typescript-eslint/eslint-plugin": "^7.0.4",
"@typescript-eslint/parser": "^7.0.4",
"cspell": "^8.12.1",
"eslint": "^8.57.0",
"fast-check": "^3.16.0",
"jest": "^29.7.0",
Expand Down
6 changes: 3 additions & 3 deletions src/detectors/builtin/divideBeforeMultiply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
* Performing division before multiplication can lead to unexpected results due to precision loss and rounding errors:
* * Precision Loss: Dividing first can result in significant precision loss, especially when dealing with integers or fixed-point numbers.
* * Rounding Errors: Early division might cause rounding errors that propagate through subsequent calculations.
* * Unexpected Behavior: Misordered operations can lead to incorrect outcomes, making debugging and maintenance more challenging.
* * Unexpected Behavior: Incorrectly ordered operations can lead to incorrect outcomes, making debugging and maintenance more challenging.
*
* ## Example
* ```tact
Expand Down Expand Up @@ -181,8 +181,8 @@ export class DivideBeforeMultiply extends Detector {
Relation.from(
"varAssign",
[
["asigneed", FactType.Symbol],
["asignee", FactType.Symbol],
["assigned", FactType.Symbol],
["assignee", FactType.Symbol],
["func", FactType.Symbol],
],
undefined,
Expand Down
2 changes: 1 addition & 1 deletion src/detectors/builtin/neverAccessedVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ interface VariableState {
}

/**
* A powerset lattice that keeps state of local varialbes within control flow.
* A powerset lattice that keeps state of local variables within control flow.
*/
class VariableUsageLattice implements JoinSemilattice<VariableState> {
bottom(): VariableState {
Expand Down
2 changes: 1 addition & 1 deletion src/detectors/builtin/zeroAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function findZeroAddress(
* contract Proxy {
* to: Address;
* init(to: Address) {
* // Fixed: Using the input value on initializaiton.
* // Fixed: Using the input value on initialization.
* self.to = to;
* }
* fun setAddress(to: Address) {
Expand Down
2 changes: 1 addition & 1 deletion src/driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ export async function run(
}

/**
* Encapsulates logic of handling single Tact contracts without user-defined configuraiton.
* Encapsulates logic of handling single Tact contracts without user-defined configuration.
*/
class SingleContractProjectManager {
private constructor(private contractPath: string) {}
Expand Down
6 changes: 3 additions & 3 deletions src/internals/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ export class MistiContext {

/**
* Initializes the context for Misti, setting up configuration and appropriate logger.
* @param params Contains various configuraiton options:
* @param params Contains various configuration options:
* - mistiConfigPath: Path to the Misti configuration file.
* - soufflePath: Directory to save Soufflé files.
* - verbose: CLI option to force verbose output.
* - quiet: CLI option to forcefuly suppress output.
* - singleContractPath: Contains path to a single contract if executed without project configuraiton.
* - quiet: CLI option to forcefully suppress output.
* - singleContractPath: Contains path to a single contract if executed without project configuration.
*/
constructor(
params: Partial<{
Expand Down
14 changes: 7 additions & 7 deletions src/internals/ir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export class TactASTStore {
* and contract constants.
* @param params Additional parameters:
* - includeStdlib: If true, includes constants defined in stdlib.
* - includeContract: If true, includes contstants defined within a contract.
* - includeContract: If true, includes constants defined within a contract.
* XXX: This won't compile since Tact 1.4.1, remove it after #22 is merged
*/
getConstants(
Expand Down Expand Up @@ -395,7 +395,7 @@ export type NodeKind =
| { kind: "regular" }
/**
* Represents a node that contains function calls in its expressions.
* `callees` refers to unique indecies of the callee within the CFG.
* `callees` refers to unique indices of the callee within the CFG.
* Functions which definitions are not available in the current
* compilation unit are omitted.
*/
Expand Down Expand Up @@ -426,7 +426,7 @@ export class Node {
}

/**
* Retuns true iff this basic block terminates control flow.
* Returns true iff this basic block terminates control flow.
*/
public isExit(): boolean {
return this.kind.kind === "return";
Expand All @@ -451,12 +451,12 @@ export class CFG {
public idx: CFGIdx;

/**
* Map from unique node indices to nodes indecies in the `this.nodes`.
* Map from unique node indices to nodes indices in the `this.nodes`.
*/
private nodesMap: Map<NodeIdx, number>;

/**
* Map from unique node indices to nodes indecies in the `this.edges`.
* Map from unique node indices to nodes indices in the `this.edges`.
*/
private edgesMap: Map<NodeIdx, number>;

Expand Down Expand Up @@ -714,7 +714,7 @@ export class CompilationUnit {
}

/**
* An utility funciton that extracts node's predecessors.
* An utility function that extracts node's predecessors.
*/
export function getPredecessors(cfg: CFG, node: Node): Node[] {
const predecessors = cfg.getPredecessors(node.idx);
Expand All @@ -727,7 +727,7 @@ export function getPredecessors(cfg: CFG, node: Node): Node[] {
}

/**
* An utility funciton that extracts node's successors.
* An utility function that extracts node's successors.
*/
export function getSuccessors(cfg: CFG, node: Node): Node[] {
const successors = cfg.getSuccessors(node.idx);
Expand Down
6 changes: 3 additions & 3 deletions src/internals/lattice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface Lattice<T> {
}

/**
* Interface for a join semilattice that introduceses the join operation.
* Interface for a join semilattice that introduces the join operation.
* @template T The type of elements in the semilattice.
*/
export interface JoinSemilattice<T> extends Lattice<T> {
Expand All @@ -33,15 +33,15 @@ export interface JoinSemilattice<T> extends Lattice<T> {
}

/**
* Interface for a meet semilattice that introduceses the meet operation.
* Interface for a meet semilattice that introduces the meet operation.
* @template T The type of elements in the semilattice.
*/
export interface MeetSemilattice<T> extends Lattice<T> {
/**
* Meets two elements of the semilattice, returning the greatest lower bound (glb) of the two elements.
* @param a First element to meet.
* @param b Second element to meet.
* @returns The meeted value, representing the combination of `a` and `b`.
* @returns The met value, representing the combination of `a` and `b`.
*/
meet(a: T, b: T): T;
}
Expand Down
2 changes: 1 addition & 1 deletion src/internals/solver/souffle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class SouffleSolver<State> implements Solver<State> {
this.cfg.forEachNode(this.cu.ast, (_stmt, node) => {
ctx.addFact("bb", Fact.from([BB_FACT(node.idx)]));
});
// TODO: replace w/ predecessors? is it convinient to access that information in user-defined rules?
// TODO: replace w/ predecessors? is it convenient to access that information in user-defined rules?
this.cfg.forEachEdge((edge) => {
ctx.addFact("edge", Fact.from([BB_FACT(edge.src), BB_FACT(edge.dst)]));
});
Expand Down
2 changes: 1 addition & 1 deletion src/internals/souffle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export {
Constraint,
makeBinConstraint,
makeMatchConstraint,
makeConstainsConstraint,
makeContainsConstraint,
makeBooleanConstraint,
} from "./rule";
export { Context } from "./context";
Expand Down
2 changes: 1 addition & 1 deletion src/internals/souffle/rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const makeMatchConstraint = (
): Constraint => {
return { kind: "match", lhs, rhs };
};
export const makeConstainsConstraint = (
export const makeContainsConstraint = (
lhs: ConstraintArg,
rhs: ConstraintArg,
): Constraint => {
Expand Down
4 changes: 2 additions & 2 deletions src/internals/tactIRBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ export class TactIRBuilder {
}

/**
* Creates the complete CFGs for contract entries using the previously registred CFG identifiers.
* Creates the complete CFGs for contract entries using the previously registered CFG identifiers.
*/
private createContracts(): Map<ContractIdx, Contract> {
return this.ast.types.reduce((acc, entry) => {
Expand Down Expand Up @@ -534,7 +534,7 @@ export class TactIRBuilder {
}

/**
* Determines kind of the basic block while creating statemenets.
* Determines kind of the basic block while creating statements.
*/
getNodeKind(stmt: ASTStatement): NodeKind {
switch (stmt.kind) {
Expand Down
6 changes: 3 additions & 3 deletions test/contracts/div-before-mul-3.tact
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
fun test(): Int {
let a: Int = 10 / 3; // Division operation
let c: Int = 2;
let taintedWitha1: Int = 2 - a;
let taintedWitha2: Int = 55 + taintedWitha1;
let result: Int = taintedWitha2 * c; // Error: Using a variable tainted with division
let taintedWithA1: Int = 2 - a;
let taintedWithA2: Int = 55 + taintedWithA1;
let result: Int = taintedWithA2 * c; // Error: Using a variable tainted with division
return result;
}

Loading

0 comments on commit db3517a

Please sign in to comment.