-
Notifications
You must be signed in to change notification settings - Fork 36
Add ollama #294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add ollama #294
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Copyright 2025 ISP RAS | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
################################################################################ | ||
|
||
ARG BASE_IMAGE="sydr/ubuntu22.04-sydr-fuzz" | ||
FROM $BASE_IMAGE | ||
|
||
# Clone Ollama. | ||
RUN git clone https://github.com/ollama/ollama.git /ollama | ||
|
||
WORKDIR /ollama | ||
|
||
RUN git checkout 05a43e078a89247dcc71c703c1bee2af97c1655d | ||
|
||
# Apply patch. | ||
COPY ollama.patch build.sh ./ | ||
RUN git apply ollama.patch | ||
|
||
# Extract corpuses. | ||
COPY corpus.zip / | ||
RUN unzip /corpus.zip -d / | ||
|
||
# Create directories for fuzz targets. | ||
RUN mkdir sydr && cd sydr && mkdir -p convert parser server harmony wordpiece | ||
|
||
# Move fuzz targets. | ||
RUN mkdir fuzz | ||
COPY fuzz.go fuzz | ||
|
||
COPY server_manifest_sydr.go sydr/server | ||
COPY parser_parsefile_sydr.go sydr/parser | ||
COPY convert_tokenizer_sydr.go sydr/convert | ||
COPY convert_vocabulary_sydr.go sydr/convert | ||
COPY harmony_parser_sydr.go /ollama/sydr/harmony | ||
COPY wordpiece_sydr.go /ollama/sydr/wordpiece | ||
|
||
# Build GGML. | ||
RUN mkdir -p build && cd build && \ | ||
CC=clang-18 CXX=clang++-18 cmake --preset 'CPU' -DGGML_AVX_VNNI=OFF .. && \ | ||
make -j | ||
|
||
# Install go-fuzz. | ||
RUN go install github.com/dvyukov/go-fuzz/go-fuzz@latest && \ | ||
go install github.com/dvyukov/go-fuzz/go-fuzz-build@latest && \ | ||
go get github.com/dvyukov/go-fuzz/go-fuzz-dep | ||
|
||
# Build targets. | ||
RUN ./build.sh | ||
|
||
WORKDIR / |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Copyright 2025 ISP RAS | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
################################################################################ | ||
|
||
ARG BASE_IMAGE="sydr/ubuntu22.04-sydr-fuzz" | ||
FROM $BASE_IMAGE | ||
|
||
ARG SYDR_ARCHIVE="./sydr.zip" | ||
|
||
WORKDIR / | ||
|
||
# Clone Ollama. | ||
RUN git clone https://github.com/ollama/ollama.git /ollama | ||
|
||
WORKDIR /ollama | ||
|
||
RUN git checkout 05a43e078a89247dcc71c703c1bee2af97c1655d | ||
|
||
# Apply patch. | ||
COPY ollama.patch build.sh ./ | ||
RUN git apply ollama.patch | ||
|
||
# Extract corpuses. | ||
COPY corpus.zip / | ||
RUN unzip /corpus.zip -d / | ||
|
||
# Create directories for fuzz targets. | ||
RUN mkdir sydr && cd sydr && mkdir -p convert/tokenizer convert/vocabulary \ | ||
parser/parsefile server/manifest harmony/parser wordpiece/encode | ||
|
||
# Move fuzz targets. | ||
RUN mkdir fuzz | ||
COPY fuzz.go fuzz | ||
|
||
COPY server_manifest_sydr.go sydr/server/manifest/main.go | ||
COPY parser_parsefile_sydr.go sydr/parser/parsefile/main.go | ||
COPY convert_tokenizer_sydr.go sydr/convert/tokenizer/main.go | ||
COPY convert_vocabulary_sydr.go sydr/convert/vocabulary/main.go | ||
COPY harmony_parser_sydr.go sydr/harmony/parser/main.go | ||
COPY wordpiece_sydr.go sydr/wordpiece/encode/main.go | ||
|
||
# Build GGML. | ||
RUN mkdir -p build && cd build && \ | ||
CC=clang-18 CXX=clang++-18 cmake --preset 'CPU' -DGGML_AVX_VNNI=OFF .. && \ | ||
make -j | ||
|
||
# Copy LibAFL-DiFuzz target template. | ||
COPY directed_target /directed_target | ||
|
||
WORKDIR /directed_target | ||
|
||
# Build image for LibAFL-DiFuzz. | ||
ADD ${SYDR_ARCHIVE} ./ | ||
RUN unzip -o ${SYDR_ARCHIVE} && rm ${SYDR_ARCHIVE} | ||
RUN OUT_DIR=/ cargo make all | ||
|
||
WORKDIR / |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
# Ollama | ||
|
||
Ollama is an application which lets you run offline large language models locally. | ||
|
||
## Build Docker | ||
|
||
$ sudo docker build -t oss-sydr-fuzz-ollama . | ||
|
||
## Build LibAFL-DiFuzz Docker | ||
|
||
Pass `sydr.zip` as an argument: | ||
|
||
$ sudo docker build --build-arg SYDR_ARCHIVE="sydr.zip" -t oss-sydr-fuzz-libafl-ollama -f ./Dockerfile_libafl . | ||
|
||
## Run Hybrid Fuzzing | ||
|
||
Unzip Sydr (`sydr.zip`) in `projects/ollama` directory: | ||
|
||
$ unzip sydr.zip | ||
|
||
Run docker: | ||
|
||
$ sudo docker run --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -v /etc/localtime:/etc/localtime:ro --rm -it -v $PWD:/fuzz oss-sydr-fuzz-ollama /bin/bash | ||
|
||
Run docker for LibAFL-DiFuzz: | ||
|
||
$ sudo docker run --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -v /etc/localtime:/etc/localtime:ro --rm -it -v $PWD:/fuzz oss-sydr-fuzz-libafl-ollama /bin/bash | ||
|
||
Change directory to `/fuzz`: | ||
|
||
# cd /fuzz | ||
|
||
Run hybrid fuzzing with libfuzzer: | ||
|
||
# sydr-fuzz -c convert_tokenizer-lf.toml run | ||
|
||
Run hybrid fuzzing with LibAFL-DiFuzz: | ||
|
||
# sydr-fuzz -c convert_tokenizer-libafl.toml run | ||
|
||
Minimize corpus (only for libfuzzer): | ||
|
||
# sydr-fuzz -c convert_tokenizer-lf.toml cmin | ||
|
||
Collect coverage: | ||
|
||
# sydr-fuzz -c convert_tokenizer-lf.toml cov-html | ||
# sydr-fuzz -c convert_tokenizer-libafl.toml cov-html | ||
|
||
## Alternative Fuzz Targets | ||
|
||
Ollama project has 10 fuzz targets. | ||
|
||
### convert_vocabulary (libfuzzer) | ||
|
||
# cd /fuzz | ||
# sydr-fuzz -c convert_vocabulary-lf.toml run | ||
|
||
### convert_vocabulary (LibAFL-DiFuzz) | ||
|
||
# cd /fuzz | ||
# sydr-fuzz -c convert_vocabulary-libafl.toml run | ||
|
||
### server_manifest (libfuzzer) | ||
|
||
# cd /fuzz | ||
# sydr-fuzz -c server_manifest-lf.toml run | ||
|
||
### server_manifest (LibAFL-DiFuzz) | ||
|
||
# cd /fuzz | ||
# sydr-fuzz -c server_manifest-libafl.toml run | ||
|
||
### parser_parsefile (libfuzzer) | ||
|
||
# cd /fuzz | ||
# sydr-fuzz -c parser_parsefile-lf.toml run | ||
|
||
### parser_parsefile (LibAFL-DiFuzz) | ||
|
||
# cd /fuzz | ||
# sydr-fuzz -c parser_parsefile-libafl.toml run | ||
|
||
### harmony_parser (libfuzzer) | ||
|
||
# cd /fuzz | ||
# sydr-fuzz -c harmony_parser-lf.toml run | ||
|
||
### harmony_parser (LibAFL-DiFuzz) | ||
|
||
# cd /fuzz | ||
# sydr-fuzz -c harmony_parser-libafl.toml run | ||
|
||
### wordpiece (libfuzzer) | ||
|
||
# cd /fuzz | ||
# sydr-fuzz -c wordpiece-lf.toml run | ||
|
||
### wordpiece (LibAFL-DiFuzz) | ||
|
||
# cd /fuzz | ||
# sydr-fuzz -c wordpiece-libafl.toml run |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.