mirror of
https://github.com/ByteAtATime/raycast-linux.git
synced 2025-08-31 11:17:27 +00:00
feat(extensions): add MacOSPathHeuristic for detecting hardcoded macOS paths
This commit introduces a new heuristic, MacOSPathHeuristic, which checks for potential hardcoded macOS paths in file content. The heuristic is added to the existing list of checks in the run_heuristic_checks function, enhancing the compatibility checks for extensions.
This commit is contained in:
parent
3ee3787a05
commit
c8b4cb58e0
1 changed files with 17 additions and 1 deletions
|
@ -38,6 +38,22 @@ impl IncompatibilityHeuristic for AppleScriptHeuristic {
|
|||
}
|
||||
}
|
||||
|
||||
struct MacOSPathHeuristic;
|
||||
impl IncompatibilityHeuristic for MacOSPathHeuristic {
|
||||
fn check(&self, command_title: &str, file_content: &str) -> Option<HeuristicViolation> {
|
||||
let macos_paths = ["/Applications/", "/Library/", "/Users/"];
|
||||
for path in macos_paths {
|
||||
if file_content.contains(path) {
|
||||
return Some(HeuristicViolation {
|
||||
command_name: command_title.to_string(),
|
||||
reason: format!("Potential hardcoded macOS path: '{}'", path),
|
||||
});
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
fn get_extension_dir(app: &tauri::AppHandle, slug: &str) -> Result<PathBuf, String> {
|
||||
let data_dir = app
|
||||
.path()
|
||||
|
@ -139,7 +155,7 @@ fn get_commands_from_package_json(
|
|||
|
||||
fn run_heuristic_checks(archive_data: &bytes::Bytes) -> Result<Vec<HeuristicViolation>, String> {
|
||||
let heuristics: Vec<Box<dyn IncompatibilityHeuristic + Send + Sync>> =
|
||||
vec![Box::new(AppleScriptHeuristic)];
|
||||
vec![Box::new(AppleScriptHeuristic), Box::new(MacOSPathHeuristic)];
|
||||
if heuristics.is_empty() {
|
||||
return Ok(vec![]);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue