Skip to content

Commit 9d4b7b7

Browse files
author
gersbach
committed
EAS-2573 : Add GraphQL support for the permission scanner
1 parent 054198a commit 9d4b7b7

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

crates/forge_analyzer/src/definitions.rs

+25-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#![allow(dead_code, unused)]
22

33
use std::borrow::BorrowMut;
4-
use std::env;
54
use std::hash::Hash;
65
use std::{borrow::Borrow, fmt, mem};
6+
use std::{env, string};
77

88
use crate::utils::{calls_method, eq_prop_name};
99
use forge_file_resolver::{FileResolver, ForgeResolver};
@@ -146,6 +146,12 @@ pub fn run_resolver(
146146

147147
// This for loop parses each token of each code statement in the file.
148148
for (curr_mod, module) in modules.iter_enumerated() {
149+
150+
let mut string_collector = StringCollector { strings: vec![] };
151+
152+
module.visit_children_with(&mut string_collector);
153+
environment.all_strings.extend(string_collector.strings);
154+
149155
let mut export_collector = ExportCollector {
150156
res_table: &mut environment.resolver,
151157
curr_mod,
@@ -583,6 +589,7 @@ pub struct Environment {
583589
pub defs: Definitions,
584590
default_exports: FxHashMap<ModId, DefId>,
585591
pub resolver: ResolverTable,
592+
pub all_strings: Vec<Atom>,
586593
}
587594

588595
struct ImportCollector<'cx> {
@@ -3298,6 +3305,23 @@ impl Visit for GlobalCollector<'_> {
32983305
}
32993306
}
33003307

3308+
struct StringCollector {
3309+
strings: Vec<Atom>,
3310+
}
3311+
3312+
impl Visit for StringCollector {
3313+
fn visit_str(&mut self, n: &Str) {
3314+
self.add_str(n);
3315+
}
3316+
}
3317+
3318+
impl StringCollector {
3319+
pub fn add_str(&mut self, n: &Str) {
3320+
let a = n.value.clone();
3321+
self.strings.push(a);
3322+
}
3323+
}
3324+
33013325
impl Visit for ExportCollector<'_> {
33023326
noop_visit_type!();
33033327
fn visit_export_decl(&mut self, n: &ExportDecl) {

crates/fsrt/src/main.rs

+2
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,8 @@ pub(crate) fn scan_directory<'a>(
460460
}
461461
}
462462

463+
// TODO: map permissions here for proj.env.all_strings, will implement after new API is merged in
464+
463465
let mut used_graphql_perms: Vec<&str> = definition_analysis_interp
464466
.value_manager
465467
.varid_to_value_with_proj

0 commit comments

Comments
 (0)