Skip to content

Commit

Permalink
EAS-2573 : Add GraphQL support for the permission scanner
Browse files Browse the repository at this point in the history
  • Loading branch information
gersbach committed Dec 23, 2024
1 parent 054198a commit 9d4b7b7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 25 additions & 1 deletion crates/forge_analyzer/src/definitions.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#![allow(dead_code, unused)]

use std::borrow::BorrowMut;
use std::env;
use std::hash::Hash;
use std::{borrow::Borrow, fmt, mem};
use std::{env, string};

use crate::utils::{calls_method, eq_prop_name};
use forge_file_resolver::{FileResolver, ForgeResolver};
Expand Down Expand Up @@ -146,6 +146,12 @@ pub fn run_resolver(

Check warning on line 146 in crates/forge_analyzer/src/definitions.rs

View workflow job for this annotation

GitHub Actions / Rustfmt

Diff in /home/runner/work/FSRT/FSRT/crates/forge_analyzer/src/definitions.rs
// This for loop parses each token of each code statement in the file.
for (curr_mod, module) in modules.iter_enumerated() {

let mut string_collector = StringCollector { strings: vec![] };

module.visit_children_with(&mut string_collector);
environment.all_strings.extend(string_collector.strings);

let mut export_collector = ExportCollector {
res_table: &mut environment.resolver,
curr_mod,
Expand Down Expand Up @@ -583,6 +589,7 @@ pub struct Environment {
pub defs: Definitions,
default_exports: FxHashMap<ModId, DefId>,
pub resolver: ResolverTable,
pub all_strings: Vec<Atom>,
}

struct ImportCollector<'cx> {
Expand Down Expand Up @@ -3298,6 +3305,23 @@ impl Visit for GlobalCollector<'_> {
}
}

struct StringCollector {
strings: Vec<Atom>,
}

impl Visit for StringCollector {
fn visit_str(&mut self, n: &Str) {
self.add_str(n);
}
}

impl StringCollector {
pub fn add_str(&mut self, n: &Str) {
let a = n.value.clone();
self.strings.push(a);
}
}

impl Visit for ExportCollector<'_> {
noop_visit_type!();
fn visit_export_decl(&mut self, n: &ExportDecl) {
Expand Down
2 changes: 2 additions & 0 deletions crates/fsrt/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,8 @@ pub(crate) fn scan_directory<'a>(
}
}

// TODO: map permissions here for proj.env.all_strings, will implement after new API is merged in

let mut used_graphql_perms: Vec<&str> = definition_analysis_interp
.value_manager
.varid_to_value_with_proj
Expand Down

0 comments on commit 9d4b7b7

Please sign in to comment.