Skip to content

Improved Notebook#13

Merged
wargio merged 34 commits intorizinorg:mainfrom
IndAlok:main
Mar 20, 2026
Merged

Improved Notebook#13
wargio merged 34 commits intorizinorg:mainfrom
IndAlok:main

Conversation

@IndAlok
Copy link
Contributor

@IndAlok IndAlok commented Mar 17, 2026

The PR simply aims to propose few major improvements to existing Notebook. It adds plugins for Rizin and Cutter, provides CI and release artifact integration, and a per-page notebook architecture. It also has binary attach and fetch, and also enhances keybindings, autocomplete, and search UX.

closes #1
closes #2
closes #3
#7 was marked not relevant

IndAlok added 30 commits March 2, 2026 03:59
…, import/export

Major architecture changes:

Go Server:
- Replace monolithic notebook.db with per-page .rznb SQLite files
- New store.go with PageDB (per-file), Catalog (directory manager), SettingsStore
- Add RecordCommandRequest/Response, ExportPageResponse, ImportPageResponse to protobuf
- Add /record, /export, /import API endpoints (both protobuf and JSON)
- Add binary_hash field to Page for integrity verification
- Add migration from legacy notebook.db and JSON formats
- Global changed from store *Store to catalog *Catalog across all server files

Rizin C Plugin (rz_notebook.c):
- Remove auto-start on plugin init (no auto-spawn)
- Add session state: g_active_page, g_connected
- New commands: NBc (connect), NBs (spawn), NBi (info), NBl (list),
  NBn (create with binary), NBo (open with hash verify), NBq (close),
  NBp (page details), NBd (delete), NBx (local exec + record),
  NBxs (server script), NBe (export .rznb), NBm (import .rznb), NBu (URL)
- NBx executes locally via rz_core_cmd_str and POSTs result to /record
- Binary hash verification on NBo using SHA-256

Cutter Plugin (CutterNotebookPlugin v2.0.0):
- Remove auto-start, add explicit Connect/Spawn buttons
- Add active page tracking with star marker in page list
- Run command locally via Core()->cmdRaw() and POST to /record
- Add Export/Import buttons and file dialogs
- Binary hash verification using QCryptographicHash::Sha256
- Scripts still execute on server

Web Templates:
- index.tmpl: Add Import .rznb button with JS upload handler
- page-view.tmpl: Add Export .rznb button, display SHA-256 hash
…file checks

Critical fixes:

1. store.go: Fix race condition in Catalog.ListPages() and Catalog.GetPage()
   - Both methods used RLock but called openPageUnlocked() which writes
     to the openPages map. Concurrent goroutines caused data races and
     Go runtime panics (the 'crashy sessions' symptom).
   - Changed from RLock/RUnlock to Lock/Unlock for correctness.

2. CutterNotebookPlugin: Fix stack overflow (0xc00000fd) crash
   - Added m_populatingPages guard flag to break infinite recursion:
     currentTextChanged -> setActivePage -> populatePages -> clear()
     -> currentTextChanged -> ... (infinite loop).
   - Guard checked in the signal handler and in populatePages entry.
   - Flag reset at all exit paths of populatePages.

3. rz_notebook.c: Add file-open check in NBx command
   - cmd_nb_exec now calls nb_current_filename() before executing.
   - If no file is open, shows clear error instead of cryptic
     'core file isn't open' from Rizin internals.

4. CutterNotebookPlugin: Add file-open check for exec-command mode
   - onSubmitEditor checks Core()->cmdRaw('o.') before running
     a local command to verify a binary is loaded in Cutter.

Also includes (from prior session):
- server_api.go: apiJSONImportPage now accepts both multipart/form-data
  and raw body (application/octet-stream) for .rznb import.
- Regenerated protobuf-c files with RecordCommand/Export/Import messages.
store.go:
- Remove CREATE INDEX from pageSchemaSQL (fails on old-schema imports
  where 'position' column doesn't exist yet)
- Add ensureColumns() called after OpenPageDB: uses PRAGMA table_info()
  to detect and add missing columns (position, executed, binary_hash)
  and handle binary->binary_key column rename via ALTER TABLE
- Rewrite ExportPage() to properly open page and WAL checkpoint under
  mutex before reading the raw .rznb file
- Rewrite ImportPage() with: stale WAL/SHM cleanup, legacy 'pages'
  table fallback, default meta creation, binary hash recomputation

rz_notebook.c:
- Add JSON fallback diagnostics to cmd_nb_info and cmd_nb_list: if
  protobuf decode fails and response body starts with '{' or '[',
  print 'Server returned JSON (expected protobuf)' with raw body
- Add raw-file fallback to cmd_nb_export: if protobuf decode fails,
  try writing raw response body as .rznb file directly

Tested: export->import round-trip, old-schema .rznb import (missing
position/executed/binary_hash columns, binary->binary_key rename)
- Add currentBinaryPath() using ij JSON for reliable file detection

- onNewPage auto-attaches loaded binary (no file dialog, mirrors rizin NBn)

- exec-command check uses currentBinaryPath instead of fragile o. command

- onAttachBinary defaults to currently loaded binary

- onOpenPipe auto-offers Cutter binary when page has none

- Increase sendJsonRequest timeout for binary uploads (30s POST, 5s GET)

- verifyBinaryHash uses currentBinaryPath for path detection
…d screenshots and minor coloring improvement for readability
@IndAlok IndAlok changed the title Improved Notebook :) Improved Notebook Mar 17, 2026
var m = matches[i];
var summ = m.cmd.summary || m.cmd.description || "";
if (summ.length > 60) summ = summ.substring(0, 57) + "…";
html +=
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please do not inject html.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please check the recent commit? (b9cad9b)

The safer DOM-building approach you suggested, was only replaced earlier (144fc75) in search integration, inspite of other injections I used elsewhere.

Also, the added helper in shortcuts.js parses rendered markdown into an inert document, rebuilds only an allowlisted safe DOM subset, strips blocked tags/attrs/protocols, and exposes NotebookSafeMarkdown.

…stances, added a simple sanitizer in shortcuts.js
@wargio wargio merged commit 7a5fcf0 into rizinorg:main Mar 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Autocomplete based on the rizin bin itself. Keep command line open till the user cancels it Keyboard shortcuts

2 participants