Commit graph

93 commits

Author SHA1 Message Date
tak:Yassan
7e1e6e5d3c
fix: update comment handling in render-binja-import-script.py (#1215)
* fix: update comment handling in render-binja-import-script.py

- ret of get_comment_at is str
+ set_comment is unkown in ver5.2

* fix: fix Binary Ninja import script's AppendComment and AppendLvarComment functions

- Remove undefined `pc` variable reference in AppendLvarComment
- Add fallback handling when get_code_refs returns no references in AppendComment
- Add null check for get_functions_containing to prevent crash
- Add bv.set_comment_at fallback when function is not found
- Add int() conversion for address parameters for type safety
- Change `return` to `continue` in AppendComment loop to annotate all references
2026-08-27 10:30:24 +02:00
1413961f62
fix(scripts): use the correct max_len constants for libs vs pes
MAX_LEN_LIBS (64) now applies to --libs and MAX_LEN_PES (100) to --pes;
they were swapped.
2026-08-19 17:47:07 +05:30
cede3de25f
fix(scripts): make --pes mode reachable in extract_strings.py
The max_len fallback branch tested args.libs twice, so --pes without an
explicit --max-len raised ValueError('unknown extraction type'). The
second condition now checks args.pes.
2026-08-19 04:48:22 +05:30
716e1fda1e
scripts: replace deprecated --no with --no-string-type
--no only works today via argparse abbreviation of --no-string-type. The
PR's planned --no-section/--no-structure/--no-tag flags will make --no an
ambiguous prefix and break these call sites. Use the canonical spelling.
2026-08-13 16:30:01 +05:30
67fc76e4e4
build_oss_db: derive default output dir from data_root
The default --output-dir hardcoded a path constructed from parents[2],
duplicating the floss/tags/data root that data_root() already provides.
Use data_root() / "oss" so the script follows the same source of truth
as query_string.py.
2026-08-13 16:06:51 +05:30
1dc265a98f
feat: migrate CLI flags and add runtime metrics
Implement the first batch of the FLOSS migration development spec.

CLI:
- remove --no-layout, --no-tags, -l/--load, -H, --no, and --only
- add --string-type and --no-string-type to replace --no and --only
- rename --functions to --analyze-functions
- load a saved JSON results document automatically from file content
- print the full option list when run with no arguments (exit 1)
- always show the full option list in --help; --version exits 0

Metrics:
- add layout and tags runtime timing fields to the results document
- record elapsed time for the layout/tag step and tag DB matching

Other:
- point the tag scripts at the current tag database location

Update the CLI tests and the usage documentation for the new flags.
2026-08-11 18:27:28 +05:30
c087754b16
style: drop nargs sample-order comments 2026-08-02 01:23:32 +05:30
b2a62e9b94
fix: CI quantumstrand trigger and --no sample argv order
Run build workflow on PRs to quantumstrand (like tests.yml). Put the
sample path before --no stack/tight/decoded so nargs="+" does not
swallow the path in the smoke test and bulk_analyze.
2026-08-02 01:12:59 +05:30
9d1f7dab4b
docs(script): add TODO for bulk analysis 2026-07-31 00:56:20 +05:30
47715efaf0
fix: harden default layout path and clean quantum leftovers
- Smoke standalone floss (not floss quantum) in build.yml
- Fall back to classic statics on any layout/tag pipeline failure
- Read the sample once and reuse the buffer for layout
- Drop deleted floss.quantum/document from PyInstaller hiddenimports
- Restore CLI/product-flag tests; fix stale qs/QuantumStrand docs
- Drop dead utf-8 encoding branch in enrich
2026-07-29 00:25:24 +05:30
03ee960612
style: drop unnecessary bulk_analyze reformats
Keep the floss.cli import change only; restore pre-existing wrapping
that already satisfies black/isort at line-length 120.
2026-07-28 07:52:10 +05:30
c090b9404c
refactor: drop floss.main re-exports; fix call sites
Stop re-exporting pipeline/CLI helpers from floss.main. Import
select_functions from floss.pipeline, StringType/set_log_config from
floss.cli, and load stack/tight string modules lazily in conftest to
avoid the identify/features circular import.
2026-07-27 17:35:58 +05:30
e06e5d7063
refactor: remove floss quantum entry point and alias
Layout-aware analysis is the default for floss; the quantum console
script and deprecated subcommand shim are no longer needed.
2026-07-27 17:25:43 +05:30
b38fcac8d3
refactor: collapse quantum entry into unified floss CLI
Deprecate floss.quantum and document dual schema; floss quantum remains
a thin alias. Update README, bulk_analyze, and QS document tests for the
unified ResultDocument.
2026-07-27 00:59:11 +05:30
9eb2e48d9a
refactor(tags): move databases from floss/qs/db/data to floss/tags/data
Update LFS attributes, data_root(), PyInstaller datas, OSS workflow,
packaging, and docs. Remove residual floss/qs package.
2026-07-27 00:59:10 +05:30
1e2ba0bf93
Simplify disassembler script usage examples
Use short script names in docstrings and scripts/README instead of
full scripts/disassemblers/ paths.
2026-07-17 01:30:10 +05:30
83f79ed999
Merge mandiant/quantumstrand and resolve script path conflicts
Keep build_oss_db under scripts/tags/ with scripts.tags import in tests,
update the OSS DB workflow path, and fix a mypy error where remaining
library names were treated as LibraryDiff objects.
2026-07-16 19:54:53 +05:30
843e957299
Fix isort import order in generate_gp_db.py 2026-07-16 16:56:21 +05:30
ee0b131839
Move extract_rust_hashes to floss/language/rust and fix script imports
Co-locate the Rust version hash regenerator with rust_version_database.py,
write output via __file__-relative paths, and bootstrap repo root on
sys.path in generate_gp_db.py so it runs when invoked directly.
2026-07-16 16:54:15 +05:30
aacf9cd0ac
Reorganize scripts into disassemblers, tags, and analysis
Group auxiliary scripts by purpose: classic FLOSS tool integrations under
disassemblers/, QuantumStrand tag DB maintenance under tags/ (including
build_oss_db.py), and batch runs under analysis/. Add category READMEs,
update tests and import paths, and point build_oss_db default output at
floss/qs/db/data/oss.
2026-07-16 16:48:26 +05:30
0a0d876afa
Include scripts/tags in mypy and fix package imports
Pre-commit already type-checks scripts/; the exclude skipped tag maintenance
scripts that import floss.tags. Add scripts package markers and mypy_path so
mypy resolves scripts.tags imports, and update the build_oss_db test import.
Also fix query_string.py to load the GP database from floss/qs/db/data/gp/.
2026-07-16 16:42:39 +05:30
c15158196f
feat(oss-db): use backticks directly 2026-07-13 21:53:55 +05:30
e751bd92e8
refactor: address mr-tz review on modular layout/tags split
Move string extraction out of layout/types into layout/extract, fold
merge_overlapping_ranges into ranges, and consolidate layout-derived tag
checks into tags/checks. Remove the unused enrich shim, add pipeline.py as
the iteration-2 enrichment placeholder, restore script usage docs, and
clarify interim document vs results schemas with docstrings.
2026-07-13 17:25:20 +05:30
e4ff998304
fix(oss-db): size markdown truncation by real footer 2026-07-13 13:54:13 +05:30
fe30edf42b
docs(oss-db): clarify capped CI diff summary 2026-07-13 13:43:08 +05:30
e2fbc3939f
fix(oss-db): address code review 2026-07-13 13:43:08 +05:30
lakshit verma
7314ce4a56
Apply suggestions from code review
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2026-07-11 17:25:22 +05:30
0c9ecfac1b
refactor: rename floss.analyze_static to floss.quantum
Provide python -m floss.quantum and a quantum console script as the
layout-aware string analysis entrypoint.
2026-07-11 16:17:08 +05:30
764e6b36c1
fix: bump msgspec for Python 3.12 wheels; restore Apache headers
msgspec 0.14.2 has no cp312 wheels and fails to build from source on
3.12. Pin 0.21.1 (wheels for 3.10–3.12) in pyproject and requirements,
add layout/tag runtime deps to requirements.txt, and restore full Apache
2.0 license headers on modularized files.
2026-07-11 15:38:10 +05:30
d5688a784a
style: fix isort/black/mypy for layout/tags refactor
Format the new modules, teach mypy about layout/tag third-party imports,
exclude scripts/tags from mypy dual-module issues, and fix a few type
errors uncovered by the full pre-commit suite.
2026-07-11 15:32:19 +05:30
d38f086d8b
refactor: split QUANTUMSTRAND into first-class layout/tags modules
Remove the floss/qs product package and qs CLI/binary packaging. Move
layout analysis into floss/layout, string tagging into floss/tags (with
DBs still under floss/qs/db/data), and extract FLOSS argparse into
floss/cli. Promote former [qs] dependencies to core install deps.
2026-07-11 15:22:44 +05:30
8ae67df594
feat(workflow): limit PR char count to 65k and reset libs 2026-07-11 14:47:31 +05:30
b767f9c83a
fix(oss-db): put library headings outside PR diff fences
Render each library as a markdown ## heading with its own ```diff
block so the PR description is readable instead of one giant fence.
2026-07-11 12:42:47 +05:30
060762a453
fix(oss-db): per-library diff limits and ```diff PR body
Truncate entry diffs per library (100 in build_diff.txt, 20 in
build_diff_pr.txt for the PR description) and render the PR body
inside a ```diff fenced code block.
2026-07-11 03:01:43 +05:30
f1de449168
feat(workflow): add string diffs in the PR 2026-07-11 01:57:07 +05:30
3821279d1a
refactor(oss-db): remove monkeypatching from orchestration tests 2026-07-08 20:13:25 +05:30
fff84063c7
refactor(oss-db): address review feedback; add orchestration tests
scripts/build_oss_db.py:
- Drop unused Iterable (typing) and field (dataclasses) imports.
- Drop unused env parameter from run(); none of the four call sites
  pass it.
- Move 'import time' to the top of the module; no lazy-loading
  justification.
- Clean up the awkward config.get('libraries',) call shape.
- Refuse to extract when the vcpkg .list file is missing instead of
  silently scanning the entire triplet lib/ directory (which would
  attribute other packages' strings/functions to the wrong library).
  Log the candidate files we deliberately skipped.
- Fix exit-code logic: with --continue-on-error, return 1 when every
  library failed so the CI step doesn't silently go green on a total
  pipeline failure (broken vcpkg, wrong jh path, etc.).

tests/test_qs_build_oss_db.py:
- Add unit tests for merge_entries (new wins on collision, dedup
  off, both empty, single-side cases).
- Add orchestration tests for main() that stub build_library/Vcpkg/
  JHExtractor: per-library output, merge with pre-existing databases,
  pre-existing libraries not in the current run are preserved,
  --continue-on-error + partial success exits 0,
  --continue-on-error + all failures exits 1, no --continue-on-error +
  any failure exits 1, build_metrics.json is written with the
  expected counts.

floss/qs/db/data/oss/readme.md:
- Add a short 'Why these build parameters' section that justifies
  the x64-windows-static / msvc143 / release choice (PE target;
  toolchain-version impact expected to be marginal) and documents
  the cross-platform string-overlap findings (similar totals, low
  per-string overlap due to ISA byte runs, section names, symbol
  conventions). Stay Windows-only since FLOSS targets PE.

34 tests passing.
2026-07-08 19:46:26 +05:30
582999e2f9
refactor(oss-db): address code review; add tests for build script
- Remove dead code: Converter.convert and the standalone count_jsonl_rows
  helper are unused anywhere in the repo.
- Avoid double-parsing: fold object/function counting into Converter.parse
  and return a ParseResult(entries, num_objects, num_functions). The old
  code called count_jsonl_rows() and parse() back-to-back, each doing a
  full json.loads pass over the same text.
- Consolidate entry schema: introduce make_db_entry() and route the four
  call sites (3 in parse, 1 in load_existing_entries) through it so the
  six-key dict shape is defined exactly once.
- Add tests/test_build_oss_db.py covering make_db_entry, Converter.parse
  (counts, dedup behavior, emit_function_names, explicit function_name
  rows, malformed lines, empty lines), and load_existing_entries
  (round-trip, missing file, malformed lines, schema tolerance, empty
  file). 22 tests, all passing.

Addresses part of #1310.
2026-07-08 05:36:30 +05:30
daaf96d6a3
docs(oss-db): fix outdated readme and stale docstrings from code review
Addresses part of #1310.

- floss/qs/db/data/oss/readme.md: rewrite the build_oss_db.py paragraph
  to reflect the current behavior (no cross-library dedup; non-rebuilt
  libraries are not rewritten), and drop trailing whitespace.
- scripts/build_oss_db.py: JHExtractor.extract returns JSONL, not CSV;
  update the docstring and the --no-deduplicate help text accordingly.
- floss/qs/db/data/oss/libraries.json: sort the library list A-Z for
  stable, predictable ordering.
2026-07-08 05:36:30 +05:30
d272c2ca32
feat(oss-db): keep strings that appear in multiple libraries
Strings that appear in 2+ libraries used to be dropped from every
database they showed up in. This silently removed legitimate
indicators when a dependency was vendored (e.g. zlib sources copied
into curl), because the vendored copy's strings would no longer point
back to zlib.

Now the same string can appear in any number of .jsonl.gz files. The
query tagger in floss/qs/main.py already emits one '#<library>' tag
per matching database, so the consumer can see the overlap directly
(a string tagged '#zlib #curl' is observed in both libraries) and
weight the indicator accordingly.

Removes:
  - find_shared_strings() and the cross-library filter loops in main()
  - the preserved_libraries rewrite block (only existed to handle
    entries removed by cross-lib dedup)
  - num_shared_removed / num_shared_strings_removed from metrics

Within-library dedup is unchanged: the same string still collapses
to one entry per library (unless --no-deduplicate is passed).
2026-07-07 15:50:09 +05:30
1c1dbfaef2
Revert "feat(oss-db): stop deduping shared strings; stamp cross-library count"
This reverts commit f0872a3ffb.
2026-07-07 15:46:24 +05:30
f0872a3ffb
feat(oss-db): stop deduping shared strings; stamp cross-library count
Strings that appeared in 2+ libraries used to be deleted from every
database, which dropped legitimate indicators when a dependency was
vendored (e.g. zlib sources copied into curl).

Instead, every entry is now stamped with the number of distinct
libraries the string appears in (OpenSourceString.count). count=1 means
the string is unique to one library; count>=2 indicates a shared
string that the consumer should weight accordingly. Strings are kept
in every database they appear in, so the vendored-dependency case
preserves the original zlib indicator.

The loader schema gains a defaulted 'count: int = 1' field, so legacy
.jsonl.gz files (no count) still decode and are interpreted as
count=1. Preserved (non-rebuilt) libraries are only rewritten when
their per-string counts actually change, so the workflow does not
produce spurious diffs on runs that don't add or remove libraries.
2026-07-07 03:12:04 +05:30
d9f704b8f9
docs(script): add copyright 2026-07-06 08:16:24 +05:30
4f6044bef4
chore(script): move the build db script to the global scripts dir 2026-07-05 21:14:19 +05:30
mr-tz
93e2b8feb7 style: auto-format with black and isort 2026-03-13 09:47:53 +00:00
pinksawtooth
04ff201472
Migrate Ghidra import script to PyGhidra with enhanced stack variable… (#1190)
* Migrate Ghidra import script to PyGhidra with enhanced stack variable annotation

Updated the script for PyGhidra (Ghidra 12.0+) compatibility, migrating from
Jython (Python 2.7) to Python 3. The main improvement is enhanced local variable
commenting that now annotates both the stack variable definition and all
instruction references to it.

Key changes:
- Add PyGhidra compatibility for Ghidra 12.0+
- Implement find_stack_var_references() to track all references to stack variables
- Update append_lvar_comment() to add EOL comments at reference sites
- Refactor using template-based code generation for better maintainability
- Add type hints and comprehensive docstrings
- Support both Pydantic v1 and v2 for result parsing

This makes the generated script more effective at annotating stack strings
by showing decoded strings at the exact instructions where they are referenced,
rather than just at the function entry point.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

* Update scripts/render-ghidra-import-script.py

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* style: format ghidra import script with black

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2026-01-12 09:29:21 +01:00
Ana Maria Martinez Gomez
ab07022ff3
[copyright + license] Fix headers
Replace the header from source code files using the following script:
```Python
for dir_path, dir_names, file_names in os.walk("flare-floss"):
    for file_name in file_names:
        try:
            file_path = f"{dir_path}/{file_name}"
            f = open(file_path, "rb+")
            content = f.read()
            m = re.search(OLD_HEADER, content)
            if not m:
                continue
            print(f"{file_path}: {m.group('year')}")
            content = content.replace(m.group(0), NEW_HEADER % m.group("year"))
            f.seek(0)
            f.write(content)
        except:
            continue
```

Some files had the copyright headers inside a `"""` comment and needed
manual changes before applying the script.

The old header had the confusing sentence `All rights reserved`, which
does not make sense for an open source license. Replace the header by
the default Google header that corrects this issue and keep floss
consistent with other Google projects.
2025-01-14 17:52:22 +01:00
Aayush Goel
73020a427b
bump-pydantic from 1.10.9 to 2.6.0 (#954)
* bump-pydantic
2024-03-19 08:23:33 +01:00
Arker123
592d9958ef Updated Rust version db and scripts 2023-12-24 13:58:34 +05:30
Diego Romeo
79bad31ea2 update code style with appropriate isort options 2023-06-27 21:44:20 +02:00