Giter Club home page Giter Club logo

Comments (11)

vergenzt avatar vergenzt commented on June 8, 2024 1

Any ideas on this? ๐Ÿ™‚ I'm really coming to depend on some Shortcuts I use for personal automation. I recently decided I'd like to convert them to Cherri, and I'd love to have some initial automated "bones" to start from!

from cherri.

vergenzt avatar vergenzt commented on June 8, 2024 1

Good to know! I've got almost a dozen shortcuts that I use on a regular basis (five of which I have set to automatically run periodically throughout the day ๐Ÿ™‚) so I'm really looking forward to getting some of this into source control! ๐Ÿ˜„

from cherri.

vergenzt avatar vergenzt commented on June 8, 2024 1

Btw it turns out that this comment is not true!

cherri/main.go

Lines 66 to 68 in 68974c0

if hasSignedBytes(shortcutBytes) {
exit("import: Unable to read Shortcut as it has been signed and the contents are encrypted.")
}

It's possible to extract the raw shortcut contents from signed shortcut files.

See https://theapplewiki.com/wiki/Apple_Encrypted_Archive:

Signed shortcuts are AEA files but they are actually not encrypted. The 32bit size for the AEA context can be found at location 0x8-0xB in the file, and the size plus 0x495c will be the starting location of an LZFSE compressed Apple Archive. (For an example of this, take a look at libshortcutsign's extract_aa_from_aea function.) After decompression, the magic number is the 4 ASCII characters "AA01".

I have an example of doing this using https://github.com/wader/fq for my own shortcuts repo I started a few weeks ago here:

https://github.com/vergenzt/shortcuts/blob/8c11c3856b2cc0b5db98e862c1737ac015b5ea05/lib/tasks/import.yaml#L31-L33

from cherri.

vergenzt avatar vergenzt commented on June 8, 2024 1

Alright so a few updates!

  1. I was able to resolve that decomp branch Go compilation error via vergenzt@d45deae.
  2. I attempted to import all of my Shortcuts! ๐Ÿ˜„ There were a number of issues. You can view the results at https://github.com/vergenzt/shortcuts/tree/main/src. For the imports that succeeded, there is a *.cherri file in the repo next to the corresponding *.plist / *.json files (I included both for each Shortcut for ease of comparison). For imports that failed, there is a *.cherri-decompile.log file containing the stderr panic output.

There were a few issues I've noticed so far:

  1. There were quite a few panics. ๐Ÿ˜… I haven't dug into the details yet.
  2. Custom actions seemed to not be extracted at all. E.g. the single custom action at https://github.com/vergenzt/shortcuts/blob/62b5893173eb1c7003f22f22efc849f5a4dd151e/src/Automation%20Utils/Fastmail%20Auth.json#L4-L10
        {
          "WFWorkflowActionIdentifier": "dk.simonbs.DataJar.GetValueIntent",
          "WFWorkflowActionParameters": {
            "UUID": "9B76AD6E-10C1-4A4E-A9F0-7CE3F3A21D3D",
            "keyPath": "fastmail-config"
          }
        }
    vs the empty *.cherri file at https://github.com/vergenzt/shortcuts/blob/62b5893173eb1c7003f22f22efc849f5a4dd151e/src/Automation%20Utils/Fastmail%20Auth.cherri.

from cherri.

vergenzt avatar vergenzt commented on June 8, 2024

Oh I just noticed the decomp branch is in progress! ๐Ÿ˜ฎ

Anything ready to test yet? ๐Ÿ˜„

from cherri.

electrikmilk avatar electrikmilk commented on June 8, 2024

Oh I just noticed the decomp branch is in progress! ๐Ÿ˜ฎ

Anything ready to test yet? ๐Ÿ˜„

Thanks for your interest in this feature!

Yes, you can test this. If you use the decomp branch and build or run from the source, you can import a Shortcut using the --import flag entering either an iCloud Shortcut URL or a path to an unsigned Shortcut file. (e.g. go run . --import=unsigned.shortcut)

Keep in mind it is currently in active development so it's likely to be buggy, especially with more complex shortcuts.

from cherri.

electrikmilk avatar electrikmilk commented on June 8, 2024

This now works very well on the decomp branch, just need to do more testing and implement more features that require specific implementation to decompile properly.

Now testing decompiling LARGE Shortcuts and comparing then fixing any incorrect decompilation. ๐Ÿ˜Ž

from cherri.

electrikmilk avatar electrikmilk commented on June 8, 2024

I'm not sure we'll ever get perfect decompilation since Cherri while it tries to be as 1-1 as possible, has conveniences and doesn't always translate 1-1. However, I've been making strides in better matching actions that are split into multiple actions for ease of use. I'm excited to see how close we CAN get.

from cherri.

vergenzt avatar vergenzt commented on June 8, 2024

Hmm btw I just tested the latest decomp branch again and I'm getting a compilation error:

$ go install github.com/electrikmilk/cherri@decomp
go: github.com/electrikmilk/[email protected] requires go >= 1.22; switching to go1.22.2
# github.com/electrikmilk/cherri
../../go/pkg/mod/github.com/electrikmilk/[email protected]/decompile.go:719:18: undefined: actionOutputs
../../go/pkg/mod/github.com/electrikmilk/[email protected]/decompile.go:720:43: undefined: actionOutputs

Any ideas?

from cherri.

electrikmilk avatar electrikmilk commented on June 8, 2024

Alright so a few updates!

  1. I was able to resolve that decomp branch Go compilation error via vergenzt@d45deae.
  2. I attempted to import all of my Shortcuts! ๐Ÿ˜„ There were a number of issues. You can view the results at https://github.com/vergenzt/shortcuts/tree/main/src. For the imports that succeeded, there is a *.cherri file in the repo next to the corresponding *.plist / *.json files (I included both for each Shortcut for ease of comparison). For imports that failed, there is a *.cherri-decompile.log file containing the stderr panic output.

There were a few issues I've noticed so far:

  1. There were quite a few panics. ๐Ÿ˜… I haven't dug into the details yet.

  2. Custom actions seemed to not be extracted at all. E.g. the single custom action at https://github.com/vergenzt/shortcuts/blob/62b5893173eb1c7003f22f22efc849f5a4dd151e/src/Automation%20Utils/Fastmail%20Auth.json#L4-L10

        {
          "WFWorkflowActionIdentifier": "dk.simonbs.DataJar.GetValueIntent",
          "WFWorkflowActionParameters": {
            "UUID": "9B76AD6E-10C1-4A4E-A9F0-7CE3F3A21D3D",
            "keyPath": "fastmail-config"
          }
        }

    vs the empty *.cherri file at https://github.com/vergenzt/shortcuts/blob/62b5893173eb1c7003f22f22efc849f5a4dd151e/src/Automation%20Utils/Fastmail%20Auth.cherri.

Yeah, we should probably at least put a raw action if we don't know what the action is by default, fill in the gaps from there so that it's at least there if it's not a standard action.

from cherri.

electrikmilk avatar electrikmilk commented on June 8, 2024

Btw it turns out that this comment is not true!

cherri/main.go

Lines 66 to 68 in 68974c0

if hasSignedBytes(shortcutBytes) {
exit("import: Unable to read Shortcut as it has been signed and the contents are encrypted.")
}

It's possible to extract the raw shortcut contents from signed shortcut files.

See https://theapplewiki.com/wiki/Apple_Encrypted_Archive:

Signed shortcuts are AEA files but they are actually not encrypted. The 32bit size for the AEA context can be found at location 0x8-0xB in the file, and the size plus 0x495c will be the starting location of an LZFSE compressed Apple Archive. (For an example of this, take a look at libshortcutsign's extract_aa_from_aea function.) After decompression, the magic number is the 4 ASCII characters "AA01".

I have an example of doing this using https://github.com/wader/fq for my own shortcuts repo I started a few weeks ago here:

https://github.com/vergenzt/shortcuts/blob/8c11c3856b2cc0b5db98e862c1737ac015b5ea05/lib/tasks/import.yaml#L31-L33

This is good stuff, thanks!

from cherri.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.