Skip to content
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

Push input through postmessage #1992

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kenduguay1
Copy link

Feature to allow pushing the input value to chef via a postMessage. This allows other websites to integrate with CyberChef by loading CyberChef in an iframe and setting its input data.

The following html can be placed into a file in the public directory to demonstrate the intended use.

<!doctype html>
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<iframe src="http://localhost:8080/", title="cyberchef", height="500px", width="70%", id="chefFrame"></iframe>
<br>
<button onclick="pushToChef()">Test</button>
<input type="text", id="dataInput">
<script>
    function pushToChef() {
        data = $("#dataInput")[0].value
        target = $("#chefFrame")[0]
        target.contentWindow.postMessage({
            "type": "dataSubmit",
            "value": data
        })
    }
</script>

@CLAassistant
Copy link

CLAassistant commented Feb 28, 2025

CLA assistant check
All committers have signed the CLA.

Add handler for message events
@kenduguay1 kenduguay1 force-pushed the push-input-through-postmessage branch from 3211a38 to 7710c5e Compare February 28, 2025 19:44
@a3957273
Copy link
Member

a3957273 commented Apr 5, 2025

This is a cool feature that I hadn't thought of before! Seems good to me. As a niche thing, could we change the postMessage format to be:

{
  id: "setInput",
  value: "data to be set..."
}

This aligns with popular libraries like redux. Plus, it mirrors the internal function call we're doing, so people have to remember less names for things!

Copy link
Member

@a3957273 a3957273 left a comment

Choose a reason for hiding this comment

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

Requested changes in other comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants