Menu

#5721 lilypond-book: Rewrite processing of snippets

Fixed
2020-02-06
2020-02-01
No

lilypond-book: Rewrite processing of snippets

The previous version relied on a stable hash() method, both for the
ordering in a set() and for the list's checksum. This probably worked
with Python 2 and up to Python 3.2, but later versions use a random
seed for invocations of hash(). This ensures different hash values for
subsequent invocations to make malicious attacks more difficult.

The new code uses hashlib.md5() and .hexdigest() instead which returns
a deterministic result across runs. It also sorts the snippets' names
which leads to more stable profiling results for 'make check'.
This change also tries to improve performance by writing snippets with
the same basename only once. Additionally it solves potential problems
if the build directory has the string '.ly' in its path.

http://codereview.appspot.com/555220043

Discussion

  • Jonas Hahnfeld

    Jonas Hahnfeld - 2020-02-01
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -8,7 +8,7 @@
    
     The new code uses hashlib.md5() and .hexdigest() instead which returns
     a deterministic result across runs. It also sorts the snippets' names
    -which leads to stable profiling results for 'make check'.
    +which leads to more stable profiling results for 'make check'.
     This change also tries to improve performance by writing snippets with
     the same basename only once. Additionally it solves potential problems
     if the build directory has the string '.ly' in its path.
    
    • Needs: -->
     
  • Anonymous

    Anonymous - 2020-02-01
    • Patch: new --> review
     
  • Anonymous

    Anonymous - 2020-02-01

    Passes make, make check and a full make doc.

     
  • Jonas Hahnfeld

    Jonas Hahnfeld - 2020-02-02

    Address comments & revert temporary workaround in master

    http://codereview.appspot.com/555220043

     
  • Anonymous

    Anonymous - 2020-02-02
    • Needs: -->
    • Patch: new --> review
    • Type: -->
     
  • Anonymous

    Anonymous - 2020-02-02

    Passes make, make check and a full make doc.

     
  • Jonas Hahnfeld

    Jonas Hahnfeld - 2020-02-02

    snippet-names-*.ly -> .txt

    http://codereview.appspot.com/555220043

     
  • Jonas Hahnfeld

    Jonas Hahnfeld - 2020-02-02
     
  • Anonymous

    Anonymous - 2020-02-02
    • Needs: -->
    • Patch: new --> review
    • Type: -->
     
  • Anonymous

    Anonymous - 2020-02-02

    Passes make, make check and a full make doc.
    (although I get all those cell counts back again, I assume this would be expected in this one case - ie. I am checking against a baseline that used .ly and now is using .txt)

     
    • Jonas Hahnfeld

      Jonas Hahnfeld - 2020-02-02

      Yes, profiling differences are expected for this change because the snippets are in a different order. However I had to revert the .txt change, it's back to .ly ;-)

       
  • Anonymous

    Anonymous - 2020-02-04
    • Patch: review --> countdown
     
  • Anonymous

    Anonymous - 2020-02-04

    Patch on countdown for Feb 6th.

     
  • Anonymous

    Anonymous - 2020-02-06
    • Patch: countdown --> push
     
  • Anonymous

    Anonymous - 2020-02-06

    Patch counted down - please push.

     
  • Jonas Hahnfeld

    Jonas Hahnfeld - 2020-02-06
    • labels: --> Fixed_2_21_0
    • status: Started --> Fixed
    • Patch: push -->
     
  • Jonas Hahnfeld

    Jonas Hahnfeld - 2020-02-06

    pushed to staging

    commit a621f28387363d4c71b90e3a0d0686a5d2bedccf
    Author:     Jonas Hahnfeld <hahnjo@hahnjo.de>
    AuthorDate: Sun Feb 2 10:36:54 2020 +0100
    Commit:     Jonas Hahnfeld <hahnjo@hahnjo.de>
    CommitDate: Thu Feb 6 12:00:42 2020 +0100
    
        Issue 5721/2: Revert "Disable Python's hash randomization"
    
        Now that lilypond-book uses a real hash function, remove the workaround.
        This reverts commit 04a0dc897629d1606d12d54b5c0e15e9cd003652.
    
    commit c2808fd480612a55ff8aec91480d9097ae05359b
    Author:     Jonas Hahnfeld <hahnjo@hahnjo.de>
    AuthorDate: Thu Jan 30 21:45:54 2020 +0100
    Commit:     Jonas Hahnfeld <hahnjo@hahnjo.de>
    CommitDate: Thu Feb 6 12:00:34 2020 +0100
    
        Issue 5721/1: lilypond-book: Rewrite processing of snippets
    
        The previous version relied on a stable hash() method, both for the
        ordering in a set() and for the list's checksum. This probably worked
        with Python 2 and up to Python 3.2, but later versions use a random
        seed for invocations of hash(). This ensures different hash values for
        subsequent invocations to make malicious attacks more difficult.
    
        The new code uses hashlib.md5() and .hexdigest() instead which returns
        a deterministic result across runs. It also sorts the snippets' names
        which leads to more stable profiling results for 'make check'.
        This change also tries to improve performance by writing snippets with
        the same basename only once. Additionally it solves potential problems
        if the build directory has the string '.ly' in its path.
    
     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.