-
Notifications
You must be signed in to change notification settings - Fork 535
feat(qs): automate OSS string database builds #1327
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
base: quantumstrand
Are you sure you want to change the base?
Changes from all commits
edd0e5e
e797372
a6bf8b6
e1cb1d0
fb06ac3
4f6044b
d9f704b
8ea3fe1
0b6f915
cf97210
f0872a3
594ce4a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| name: Build OSS String Databases | ||
|
|
||
| on: | ||
| # Rebuild the databases bi-weekly (1st and 15th of each month at 00:00 UTC). | ||
| schedule: | ||
| - cron: '0 0 1,15 * *' | ||
|
|
||
| # Allow manual runs from the Actions tab. | ||
| workflow_dispatch: | ||
|
|
||
| # Cancel any in-progress run when a newer one starts. | ||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| build-databases: | ||
| name: Build OSS string databases | ||
| runs-on: windows-latest | ||
|
|
||
| env: | ||
| # Workaround for zydis 3.1.3's CMakeLists.txt requiring an older | ||
| # cmake_minimum_required syntax. Remove once Lancelot updates zydis. | ||
| CMAKE_POLICY_VERSION_MINIMUM: '3.5' | ||
|
|
||
| steps: | ||
| - name: Checkout flare-floss | ||
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 | ||
| with: | ||
| path: flare-floss | ||
| lfs: true | ||
|
|
||
| - name: Checkout lancelot | ||
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 | ||
| with: | ||
| repository: williballenthin/lancelot | ||
| path: lancelot | ||
| lfs: true | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 | ||
| with: | ||
| python-version: '3.12' | ||
|
|
||
| - name: Set up Rust | ||
| uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable | ||
|
|
||
| - name: Build jh | ||
| run: | | ||
| cargo build --release -p lancelot-bin | ||
| working-directory: lancelot | ||
|
|
||
| - name: Build OSS databases | ||
| run: | | ||
| python scripts/build_oss_db.py ` | ||
| --config floss\qs\db\data\oss\libraries.json ` | ||
| --jh-path ..\lancelot\target\release\jh.exe ` | ||
| --output-dir floss\qs\db\data\oss ` | ||
| --continue-on-error | ||
| working-directory: flare-floss | ||
|
|
||
| - name: Show metrics summary | ||
| if: success() || failure() | ||
| run: | | ||
| Get-Content floss\qs\db\data\oss\build_metrics.json | ||
| working-directory: flare-floss | ||
|
|
||
| - name: Create Pull Request if databases changed | ||
| uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6.1.0 | ||
| with: | ||
| path: flare-floss | ||
| base: quantumstrand | ||
| commit-message: 'chore(oss-db): update string databases' | ||
| title: 'Update OSS string databases' | ||
| body: | | ||
| Automated bi-weekly rebuild of the OSS string databases. | ||
|
|
||
| - Triplet: `x64-windows-static` | ||
| - Compiler: `msvc143` | ||
| - Library list: see `floss/qs/db/data/oss/libraries.json` | ||
|
|
||
| Per-library entry counts and timing are in `floss/qs/db/data/oss/build_metrics.json`. | ||
| branch: update-oss-string-databases | ||
| delete-branch: true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| { | ||
| "triplet": "x64-windows-static", | ||
| "compiler": "msvc143", | ||
| "profile": "release", | ||
| "libraries": [ | ||
| "openssl", | ||
| "capnproto", | ||
| "raylib", | ||
| "libgit2", | ||
| "libxml2", | ||
| "libimobiledevice", | ||
| "libarchive", | ||
| "libmysql", | ||
| "libhv", | ||
| "cello", | ||
| "czmq", | ||
| "boost-test", | ||
| "wolfssl", | ||
| "boost-wave", | ||
| "curl", | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isn't zlib a dep of curl, so does that mean the zlib strings get filter as duplicate, rather than being assigned to zlib? how do you handle this dependency issue?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. vcpkg builds curl and zlib as separate static .lib files so you can also see a very minimal string overlap in my local fork: vee1e#9
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing these would be bad
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agree that when the dependency is via linking, then things may work out. but in some cases the dependency may be vendored, ie, source code copied into the project. in this case, i think the strings will be detected as duplicates. to be clear, i believe this is a hard problem to handle generically. though maybe it can also be solved by a little research and hacks/configs/shorcuts.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. instead of removing duplicates altogether should we be upfront to the user and tell them exactly how commonly a string was found? maybe if its truly unique we can indicate it as a "pure" indicator tag, and with every subsequent instance of the string being found we can somehow show the library tag (#zlib etc) as "less" of a true oracle for its source.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keeping duplicates around may be the safer bet for now until we see more of this in practice or do more research into the overlaps. |
||
| "poco", | ||
| "nng", | ||
| "libsrt", | ||
| "sail", | ||
| "mbedtls", | ||
| "boost-log", | ||
| "libsndfile", | ||
| "libevent", | ||
| "libcoap", | ||
| "sqlite3", | ||
| "sdl2", | ||
| "libbson", | ||
| "mongoose", | ||
| "duktape", | ||
| "libpcap", | ||
| "expat", | ||
| "libuv", | ||
| "llhttp", | ||
| "jansson", | ||
| "tinyfiledialogs", | ||
| "hiredis", | ||
| "zyre", | ||
| "boost-json", | ||
| "boost-serialization", | ||
| "tre", | ||
| "zlib", | ||
| "boost-graph", | ||
| "apr", | ||
| "libev", | ||
| "flatcc", | ||
| "boost-filesystem", | ||
| "boost-iostreams", | ||
| "oniguruma", | ||
| "libyaml", | ||
| "cunit", | ||
| "avro-c", | ||
| "lz4", | ||
| "parson", | ||
| "json-c", | ||
| "libzip", | ||
| "boost-container", | ||
| "lzo", | ||
| "liblzma", | ||
| "boost-chrono", | ||
| "lmdb", | ||
| "binn", | ||
| "boost-thread" | ||
| ] | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -94,3 +94,19 @@ These files are then gzip'd: | |
| ```console | ||
| $ gzip -c zlib.jsonl > zlib.jsonl.gz | ||
| ``` | ||
|
|
||
| The `build_oss_db.py` script automates the steps above and additionally | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i like that the logic lives in this script, and that the GH workflow is minimal. this reduces our dependence on GH, which i believe is prudent. |
||
| removes strings that appear in two or more libraries from every database. | ||
| A shared string is not a unique identifier for any specific library, so | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as noted above: unless one library links or vendors another library. |
||
| attributing it would produce false-positive library matches at query time. | ||
|
|
||
| The script also merges into any `.jsonl.gz` already present in the output | ||
| directory rather than replacing them. For each library being rebuilt, the | ||
| newly-extracted entries are combined with the existing entries (new entries | ||
| win on string collisions, which is the right behavior when the library | ||
| version changes). Libraries that are not in the current `--libraries` list | ||
| are also re-checked against the cross-library dedup and rewritten if the | ||
| shared-string set changes. This makes it safe to incrementally add a new | ||
| library (e.g. `python build_oss_db.py --libraries newlib`) without losing | ||
| the other databases, and safe to bump one library's version while leaving | ||
| its previously-committed entries around. | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how is this chosen and when should this be updated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what effect, if any, does it have on the compilation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
taken directly from the existing qs documentation
flare-floss/floss/qs/db/data/oss/readme.md
Lines 48 to 52 in 0fbe890
i tried the builds locally on macosx-arm64. no significant differences in string counts was observed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What builds did you try?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i probably picked 143 at the time because it was probably the latest version or something. i assume there's not a major difference between versions, but we should document our expectations and assumptions. that's why i raise it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using raw strings on both I got this:
So there is a difference in strings but the total count remains similar. I didn't look at which strings overlapped before, hence the slightly wrong conclusion that there was no difference. But most of the lack of overlap can be attributed to:
strings -n 4. Different ISAs produce different random byte runs, so the noise never overlaps.It could be worth building another db set for different platforms if we want to cover all possible executables, but it'll increase build times and cost. I think its a fair point to debate imo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment here was on the msvc version :) interesting additional information though. With our PE focus we should stick to Windows for now.