Coder Social home page Coder Social logo

Comments (2)

utkonos avatar utkonos commented on July 21, 2024

@tlansec Thanks for the report. We have had a lengthy discussion about this topic in #53

I am amenable to an additional non-default option that removes imports from rules that don't use it, but the behavior you're reporting is expected and by design.

from plyara.

tlansec avatar tlansec commented on July 21, 2024

It might be the design, but I expect I will not be the last user who is surprised by this behaviour - a common use case for plyara might be:

import plyara 
# whatever the rebuild_rule import is
with open('foo.yar, 'r') as infile:
    data = infile.read()

p = plyara.Plyara()
parsed = p.parse_string(data)
accepted_rules = []
for rule in parsed:
     # do some check, and if it passes.
     accepted_rules.append(rebuild_rule(rule))
# write all the accepted_rules to a new file.

Thus ending up with a large # of unnecessary imports. I appreciate that there isn't an elegant solution to this.

If any future readers come across this thread and the library is still working as described in this issue and #53, I found the best solution is to stop using rebuild_rule if you are not modifying the contents of the rule - instead use the start_line and stop_line to build the rule from the original string again.

Cheers,
Tom

from plyara.

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.