Skip to content

feat(memvault): add secure in-memory vault with docs#73

Draft
jithinkunjachan wants to merge 1 commit intomainfrom
feat/add-memvault
Draft

feat(memvault): add secure in-memory vault with docs#73
jithinkunjachan wants to merge 1 commit intomainfrom
feat/add-memvault

Conversation

@jithinkunjachan
Copy link
Copy Markdown
Contributor

@jithinkunjachan jithinkunjachan commented Mar 3, 2026

  • Introduce MemVaultData for secure memory regions backed by mmap'd anonymous
    memory, locked to RAM, and supporting read-only protection via mprotect.
  • Includes destroy functionality for secure zeroing and unmapping.
  • Add platform specific alloc and NoDump implementations for Darwin and Linux.
  • Provide unit and integration tests for vault creation, destruction, and read-only behavior.

@jithinkunjachan jithinkunjachan self-assigned this Mar 3, 2026
@push-tags-from-workflow push-tags-from-workflow bot added dependencies Pull requests that update a dependency file tests feature labels Mar 3, 2026
)

type (
SessionHandler func(context.Context, *VaultSession) error
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Lets just call it securemem.Handler


type (
SessionHandler func(context.Context, *VaultSession) error
VaultSession struct {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Let's call this HandlerRequest because it will be the same naming logic as the other things we are gonna build

}
}

func (r *VaultSession) Put(name string, data []byte) error {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why do we need the (non persistent) Put here?


type (
SessionHandler func(context.Context, *VaultSession) error
VaultSession struct {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This should be concurrency safe

}

sess := newVaultSession()
state := newVaultSession()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think we don't need to allocate this here since we are only using it in line 80+.

assert.NoError(t, err)
assert.NotNil(t, state)

actResult, ok := state.Get(key2)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

we need to assert.Panic that this is read-only

"golang.org/x/sys/unix"
)

func readonly(data []byte) error {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

makeReadOnly

return unix.Mprotect(data, unix.PROT_READ)
}

func readwrite(data []byte) error {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

makeReadWrite


import "errors"

type VaultData struct {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

this needs to be concurrency safe and we should use an RWMutex. Because when we destroy we even want to block any read.

return unalloc(m.data)
}

func (m *VaultData) Readonly() error {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

MakeReadOnly

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 12, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c9dbd211-acc2-4275-a7db-c12ec447084b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/add-memvault
📝 Coding Plan for PR comments
  • Generate coding plan

Comment @coderabbitai help to get the list of available commands and usage tips.

Introduce MemVaultData for secure memory regions backed by mmap'd anonymous
memory, locked to RAM, and supporting read-only protection via mprotect.
Includes destroy functionality for secure zeroing and unmapping. Add platform
specific alloc and NoDump implementations for Darwin and Linux. Provide unit
and integration tests for vault creation, destruction, and read-only behavior.
Update .gitignore for macOS and test artifacts. Update dependencies.
@jithinkunjachan jithinkunjachan marked this pull request as ready for review March 18, 2026 11:12
@jithinkunjachan jithinkunjachan marked this pull request as draft March 25, 2026 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file dev-ops feature tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants