adjust negative hex numbers in to_yaml

This commit is contained in:
Moritz Raabe
2021-01-27 18:36:03 +01:00
parent d6e73577af
commit 072e30498b
3 changed files with 9 additions and 11 deletions

View File

@@ -14,7 +14,6 @@ Unless required by applicable law or agreed to in writing, software distributed
is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
"""
import re
import sys
import logging
import argparse
@@ -60,9 +59,6 @@ def main(argv=None):
rule = capa.rules.Rule.from_yaml_file(args.path, use_ruamel=True)
reformatted_rule = rule.to_yaml()
# fix negative numbers
reformatted_rule = re.sub(r"!!int '0x-([0-9a-fA-F]+)'", r"-0x\1", reformatted_rule)
if args.check:
if rule.definition == reformatted_rule:
logger.info("rule is formatted correctly, nice! (%s)", rule.name)