question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

rule generator: insert default child statement when specifying basic block subscope

See original GitHub issue

The rule generator recognizes the following as a valid rule (Rule compiled and matched):

  features:
    - and:
      - offset: 0x10
      - offset: 0x14

But it complains that when adding a basic block (failed to match rule):

  features:
    - and:
      - offset: 0x10
      - basic block:
        - offset: 0x14

Adding an extra element to the basic block, it claims that it failed to compile the rule (invalid rule: subscope must have exactly one child statement):

  features:
    - and:
      - basic block:
        - offset: 0x14
        - offset: 0x10

https://user-images.githubusercontent.com/16052290/110840578-2e201000-82a5-11eb-99e5-98c57fea8199.mov

It looks like something is wrong with basic blocks as both should be valid rules and match.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
mr-tzcommented, Mar 16, 2021

Yes, I think checking the type makes sense.

1reaction
mike-hunhoffcommented, Mar 16, 2021

Hm I’m guessing the second rule is “valid” in the sense that it contains exactly one child element, but capa won’t be able to find a match for it because the type of the child statement is not as expected. If you nested - offset: 0x14 underneath an and or or statement then the rule is valid and capa should be able to find a match for it.

We should modify the check to verify that a subscope has exactly one child element AND it’s of the expected type. Unless this additional check is performed later?

Thoughts @mr-tz?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Java - Coding Rules
This rule raises an issue when classes with non- private constructors (including the default constructor) use field injection. Noncompliant Code Example. class ...
Read more >
@babel/plugin-transform-block-scoped-functions | Yarn - Package ...
Fast, reliable, and secure dependency management.
Read more >
Simple Presentation Web App Generator
To add more slides to a SPWAG presentation, simply define another slide. ... The end keyword ends a block of code, started by...
Read more >
Computer Language & Compilers
is the description of method (rules) of how to construct a certain ... default: raise ERROR; ... A Basic Block is a consecutive...
Read more >
Visitor-based Attribute Grammars with ... - ScienceDirect.com
Abstract. The visitor design pattern is often applied to program traversal algorithms over Abstract Syntax Trees. (ASTs). It defines a visitor, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found