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

Nemoznost podpisat cez API prilohu, ktora nema filename #77

Closed
jsuchal opened this issue Nov 16, 2022 · 2 comments
Closed

Nemoznost podpisat cez API prilohu, ktora nema filename #77

jsuchal opened this issue Nov 16, 2022 · 2 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@jsuchal
Copy link
Member

jsuchal commented Nov 16, 2022

Cez API sa neda podpisat subor ak sa neposle filename (zhavaruje to). Kedze:

public void saveToFile(Document document) {
        try {
            if (!(fileExists(savedDocument))) {
                var prefix = Files.getNameWithoutExtension(document.getFilename());
                var suffix = "." + Files.getFileExtension(document.getFilename());

                savedDocument = File.createTempFile(prefix, suffix);
                savedDocument.setExecutable(true, false);
                Files.write(document.getContent(), savedDocument);
            }
            savedDocument.deleteOnExit();

        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

document.getFilename je null a na getNameWithuoExtension to padne.

Toto treba cele domysliet, ze ako sa bude detekovat typ suboru, ktory je potrebny pre vizualizaciu a co vlastne dovolime vizualizovat (resp zobrazit otvorenim). Mozu to byt podvhnute subory co otvara nove vektory utoku. Ktovie co sa stane, ked podvrhnem png alebo nieco a vo vnutri bude nieco uplne ine. Zatial riesene whitelistingom, ale neviem ci to je nepriestrelne.

PS. Taktiez sa mi tam dost nepaci ten setExecutable, kedze moze ist o podvrhnuty subor.

@jsuchal jsuchal added the bug Something isn't working label Nov 16, 2022
@jsuchal jsuchal added this to the MVP milestone Nov 16, 2022
@jsuchal
Copy link
Member Author

jsuchal commented Nov 16, 2022

Takto posiela napriklad PNG extension (bez filename) a teda to nevieme podpisat. @pomali filename sa neda posielat - resp nejaky mimetype alebo nieco sa tam neposiela standardne?

@celuchmarek
Copy link
Member

@jsuchal dnes sa už dá aj ASiCom podpísať aj súbor bez názvu (default mu to dá detached-file). A payloadMimeType je povinný a obrázok sa už vie normálne zobraziť.

Tento kód robí aj nejaký saveToFile, čo je asi niečo staré. Zavrel by som.

@jsuchal jsuchal closed this as completed Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants