GranularFireplace commited on
Commit
576ef61
·
verified ·
1 Parent(s): a7c3338

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -12
app.py CHANGED
@@ -120,26 +120,23 @@ def compile_yara_rules(repo_path: Path) -> Optional[yara.Rules]:
120
  yara_files = list(repo_path.glob("**/*.yara"))
121
 
122
  if not yara_files:
123
- logger.warning("No valid YARA files after preprocessing")
124
  return None
125
 
126
- logger.info(f"Compiling {len(yara_files)} processed YARA files")
127
  rules = {}
128
 
129
  for yara_file in yara_files:
130
  try:
131
- # Use namespace based on file path to avoid conflicts
132
- namespace = str(yara_file.relative_to(processed_dir)).replace('/', '_')
133
- rules[namespace] = str(yara_file)
134
  except Exception as e:
135
- logger.warning(f"Error adding {yara_file}: {str(e)}")
136
 
137
- # Compile with error handling
138
- try:
139
- return yara.compile(filepaths=rules, error_on_warning=False)
140
- except yara.SyntaxError as e:
141
- logger.error(f"YARA syntax error in processed rules: {str(e)}")
142
- return None
143
 
144
  except Exception as e:
145
  logger.error(f"Error compiling YARA rules: {str(e)}")
 
120
  yara_files = list(repo_path.glob("**/*.yara"))
121
 
122
  if not yara_files:
123
+ logger.warning("No YARA files found in repository")
124
  return None
125
 
126
+ logger.info(f"Found {len(yara_files)} YARA files, compiling rules")
127
  rules = {}
128
 
129
  for yara_file in yara_files:
130
  try:
131
+ rules[str(yara_file)] = str(yara_file)
 
 
132
  except Exception as e:
133
+ logger.warning(f"Error processing {yara_file}: {str(e)}")
134
 
135
+ return yara.compile(filepaths=rules)
136
+
137
+ except yara.SyntaxError as e:
138
+ logger.error(f"YARA syntax error: {str(e)}")
139
+ return None
 
140
 
141
  except Exception as e:
142
  logger.error(f"Error compiling YARA rules: {str(e)}")