Skip to content

Commit

Permalink
Merge branch 'master' into feat/rework-mutators
Browse files Browse the repository at this point in the history
  • Loading branch information
anishnaik authored Jan 14, 2025
2 parents 9d95a8e + 67cf48e commit 1f31618
Show file tree
Hide file tree
Showing 41 changed files with 1,235 additions and 111 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
needs: [lint, test]
strategy:
matrix:
environment: [ubuntu-latest, macos-12, macos-14, windows-latest]
environment: [ubuntu-latest, macos-13, macos-14, windows-latest]
permissions:
contents: read
id-token: write
Expand Down Expand Up @@ -82,7 +82,7 @@ jobs:
- name: Sign artifact
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
uses: sigstore/gh-action-sigstore-python@v2.1.1
uses: sigstore/gh-action-sigstore-python@v3.0.0
with:
inputs: ./medusa-*.tar.gz

Expand All @@ -92,7 +92,7 @@ jobs:
name: medusa-${{ runner.os }}-${{ runner.arch }}
path: |
./medusa-*.tar.gz
./medusa-*.tar.gz.sigstore
./medusa-*.tar.gz.sigstore.json
release:
needs: [build]
Expand All @@ -117,7 +117,7 @@ jobs:
name: "${{ github.ref_name }}"
files: |
./medusa-*.tar.gz
./medusa-*.tar.gz.sigstore
./medusa-*.tar.gz.sigstore.json
lint:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -165,7 +165,7 @@ jobs:
test:
strategy:
matrix:
environment: [ubuntu-latest, macos-12, macos-14, windows-latest]
environment: [ubuntu-latest, macos-13, macos-14, windows-latest]

runs-on: ${{ matrix.environment }}
timeout-minutes: 20
Expand Down Expand Up @@ -214,7 +214,7 @@ jobs:

- name: Install Python dependencies
run: |
pip3 install --no-cache-dir solc-select crytic-compile
pip3 install --no-cache-dir solc-select slither-analyzer
- name: Install solc
run: |
Expand Down
56 changes: 56 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Docker

on:
push:
branches:
- master
tags:
- "*"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
id: buildx
with:
install: true

- name: Set Docker metadata
id: metadata
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}
tags: |
type=ref,event=tag
type=ref,event=branch,prefix=testing-
type=edge
- name: GitHub Container Registry Login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker Build and Push
uses: docker/build-push-action@v6
with:
platforms: linux/amd64
target: final-ubuntu
file: Dockerfile
pull: true
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
cache-from: ${{ (github.event_name != 'schedule' && 'type=gha') || '' }}
cache-to: type=gha,mode=max
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@

# Dependency directories (remove the comment below to include it)
# vendor/
*node_modules/

# Goland project dir
.idea/

*node_modules/

# Medusa binary
medusa

# Medusa docs
docs/book

# Build results
result
2 changes: 1 addition & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @Xenomega @anishnaik @0xalpharush
* @Xenomega @anishnaik
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ To run

- Ensure JSON keys are `camelCase` rather than `snake_case`, where possible.

### Nix considerations

- If any dependencies are added or removed, the `vendorHash` property in ./flake.nix will need to be updated. To do so, run `nix build`. If it works, you're good to go. If a change is required, you'll see an error that looks like the following. Replace the `specified` value of `vendorHash` in the medusa package of flake.nix with what nix actually `got`.

```
error: hash mismatch in fixed-output derivation '/nix/store/sfgmkr563pzyxzllpmwxdbdxgrav8y1p-medusa-0.1.8-go-modules.drv':
specified: sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
got: sha256-12Xkg5dzA83HQ2gMngXoLgu1c9KGSL6ly5Qz/o8U++8=
```

## License

The license for this software can be found [here](./LICENSE).
53 changes: 53 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
## medusa build process
FROM golang:1.22 AS medusa

WORKDIR /src
COPY . /src/medusa/
RUN cd medusa && \
go build -trimpath -o=/usr/local/bin/medusa -ldflags="-s -w" && \
chmod 755 /usr/local/bin/medusa


## Python dependencies
FROM ubuntu:noble AS builder-python3
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-suggests --no-install-recommends \
gcc \
python3 \
python3-dev \
python3-venv
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
ENV PIP_NO_CACHE_DIR=1
RUN python3 -m venv /venv && /venv/bin/pip3 install --no-cache --upgrade setuptools pip
RUN /venv/bin/pip3 install --no-cache slither-analyzer solc-select


## final image assembly
FROM ubuntu:noble AS final-ubuntu

RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-suggests --no-install-recommends \
ca-certificates \
curl \
git \
jq \
python3 \
&& \
rm -rf /var/lib/apt/lists/*

# Include python tools
COPY --from=builder-python3 /venv /venv
ENV PATH="$PATH:/venv/bin"

# Include JS package managers, actions/setup-node can get confused if they're not around
RUN curl -fsSL https://raw.githubusercontent.com/tj/n/v10.1.0/bin/n -o n && \
if [ ! "a09599719bd38af5054f87b8f8d3e45150f00b7b5675323aa36b36d324d087b9 n" = "$(sha256sum n)" ]; then \
echo "N installer does not match expected checksum! exiting"; \
exit 1; \
fi && \
cat n | bash -s lts && rm n && \
npm install -g n yarn && \
n stable --cleanup && n prune && npm --force cache clean

# Include medusa
COPY --chown=root:root --from=medusa /usr/local/bin/medusa /usr/local/bin/medusa
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ The master branch can be installed using the following command:
brew install --HEAD medusa
```

For more information on building from source or obtaining binaries for Windows and Linux, please refer to the [installation guide](./docs/src/getting_started/installation.md).
For more information on building from source, using nix, or obtaining binaries for Windows and Linux, please refer to the [installation guide](./docs/src/getting_started/installation.md).

## Contributing

Expand Down
2 changes: 1 addition & 1 deletion chain/test_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ func TestChainCloning(t *testing.T) {
})
}

// TestCallSequenceReplayMatchSimple creates a TestChain, sends some messages to it, then creates another chain which
// TestChainCallSequenceReplayMatchSimple creates a TestChain, sends some messages to it, then creates another chain which
// it replays the same sequence on. It ensures that the ending state is the same.
// Note: this does not set block timestamps or other data that might be non-deterministic.
// This does not test replaying with a previous call sequence with different timestamps, etc. It expects the TestChain
Expand Down
46 changes: 45 additions & 1 deletion cmd/fuzz_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,16 @@ func addFuzzFlags() error {
fmt.Sprintf("print the execution trace for every element in a shrunken call sequence instead of only the last element (unless a config file is provided, default is %t)", defaultConfig.Fuzzing.Testing.TraceAll))

// Logging color
fuzzCmd.Flags().Bool("no-color", false, "disabled colored terminal output")
fuzzCmd.Flags().Bool("no-color", false, "disables colored terminal output")

// Enable stop on failed test
fuzzCmd.Flags().Bool("fail-fast", false, "enables stop on failed test")

// Exploration mode
fuzzCmd.Flags().Bool("explore", false, "enables exploration mode")

// Run slither on-the-fly
fuzzCmd.Flags().Bool("use-slither", false, "runs slither")
return nil
}

Expand Down Expand Up @@ -163,5 +171,41 @@ func updateProjectConfigWithFuzzFlags(cmd *cobra.Command, projectConfig *config.
return err
}
}

// Update stop on failed test feature
if cmd.Flags().Changed("fail-fast") {
failFast, err := cmd.Flags().GetBool("fail-fast")
if err != nil {
return err
}
projectConfig.Fuzzing.Testing.StopOnFailedTest = failFast
}

// Update configuration to exploration mode
if cmd.Flags().Changed("explore") {
explore, err := cmd.Flags().GetBool("explore")
if err != nil {
return err
}
if explore {
projectConfig.Fuzzing.Testing.StopOnFailedTest = false
projectConfig.Fuzzing.Testing.StopOnNoTests = false
projectConfig.Fuzzing.Testing.AssertionTesting.Enabled = false
projectConfig.Fuzzing.Testing.PropertyTesting.Enabled = false
projectConfig.Fuzzing.Testing.OptimizationTesting.Enabled = false
}
}

// Update configuration to run slither
if cmd.Flags().Changed("use-slither") {
useSlither, err := cmd.Flags().GetBool("use-slither")
if err != nil {
return err
}
if useSlither {
projectConfig.Slither.UseSlither = true
}
}

return nil
}
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"os"
)

const version = "0.1.6"
const version = "0.1.8"

// rootCmd represents the root CLI command object which all other commands stem from.
var rootCmd = &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion compilation/abiutils/solidity_errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func GetPanicReason(panicCode uint64) string {
case PanicCodeAssertFailed:
return "panic: assertion failed"
case PanicCodeArithmeticUnderOverflow:
return "panic: arithmetic underflow"
return "panic: arithmetic underflow/overflow"
case PanicCodeDivideByZero:
return "panic: division by zero"
case PanicCodeEnumTypeConversionOutOfBounds:
Expand Down
2 changes: 1 addition & 1 deletion compilation/platforms/crytic_compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func (c *CryticCompilationConfig) Compile() ([]types.Compilation, string, error)
}

// Retrieve the source unit ID
sourceUnitId := ast.GetSourceUnitID()
sourceUnitId := types.GetSrcMapSourceUnitID(ast.Src)
compilation.SourcePathToArtifact[sourcePath] = types.SourceArtifact{
// TODO: Our types.AST is not the same as the original AST but we could parse it and avoid using "any"
Ast: source.AST,
Expand Down
2 changes: 1 addition & 1 deletion compilation/platforms/solc.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (s *SolcCompilationConfig) Compile() ([]types.Compilation, string, error) {
}

// Get the source unit ID
sourceUnitId := ast.GetSourceUnitID()
sourceUnitId := types.GetSrcMapSourceUnitID(ast.Src)
// Construct our compiled source object
compilation.SourcePathToArtifact[sourcePath] = types.SourceArtifact{
// TODO our types.AST is not the same as the original AST but we could parse it and avoid using "any"
Expand Down
Loading

0 comments on commit 1f31618

Please sign in to comment.