Skip to content

Commit 9e9cd1a

Browse files
Merge remote-tracking branch 'origin/main' into eas-3876-manifest-secrets
2 parents 0471746 + 457c926 commit 9e9cd1a

6 files changed

Lines changed: 361 additions & 6 deletions

File tree

crates/forge_analyzer/src/checkers.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,18 @@ impl<'cx> Runner<'cx> for SecretChecker {
997997
SecretVuln::new(interp.callstack(), interp.env(), interp.entry());
998998
info!("Found a vuln!");
999999
self.vulns.push(vuln);
1000+
} else if let Some(Value::Const(_) | Value::Phi(_)) = interp.get_value(
1001+
def,
1002+
*varid,
1003+
projvec_from_str("X-Automation-Webhook-Token").into(),
1004+
) && interp
1005+
.get_value(def, *varid_argument, Some(projvec_from_str("method")))
1006+
.is_some_and(|x| *x == *"POST")
1007+
{
1008+
let vuln =
1009+
SecretVuln::new(interp.callstack(), interp.env(), interp.entry());
1010+
info!("Webhook token found!");
1011+
self.vulns.push(vuln);
10001012
}
10011013
}
10021014
}

crates/forge_analyzer/src/definitions.rs

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3450,8 +3450,22 @@ impl Visit for GlobalCollector<'_> {
34503450
let mut all_module_items = Vec::new();
34513451

34523452
for item in &n.body {
3453-
if let ModuleItem::Stmt(stmt) = item {
3454-
all_module_items.push(stmt.clone());
3453+
match item {
3454+
// TODO handle all cases
3455+
ModuleItem::Stmt(stmt) => all_module_items.push(stmt.clone()),
3456+
ModuleItem::ModuleDecl(mod_decl) => match mod_decl {
3457+
ModuleDecl::ExportDecl(export_decl) => {
3458+
all_module_items.push(Stmt::Decl(export_decl.decl.clone()))
3459+
}
3460+
ModuleDecl::ExportAll(_)
3461+
| ModuleDecl::ExportDefaultDecl(_)
3462+
| ModuleDecl::ExportDefaultExpr(_)
3463+
| ModuleDecl::ExportNamed(_)
3464+
| ModuleDecl::TsExportAssignment(_)
3465+
| ModuleDecl::Import(_)
3466+
| ModuleDecl::TsImportEquals(_)
3467+
| ModuleDecl::TsNamespaceExport(_) => {}
3468+
},
34553469
}
34563470
}
34573471
analyzer.lower_stmts(all_module_items.as_slice());
@@ -4251,3 +4265,37 @@ impl PartialEq<str> for ImportKind {
42514265
}
42524266
}
42534267
}
4268+
4269+
impl PartialEq<str> for Value {
4270+
#[inline]
4271+
fn eq(&self, other: &str) -> bool {
4272+
match self {
4273+
Self::Const(Const::Literal(s)) => **s == *other,
4274+
Self::Phi(v) if !v.is_empty() => v.iter().all(|x| *x == *other),
4275+
Self::Uninit | Self::Unknown | Self::Object(_) | Self::Phi(_) => false,
4276+
}
4277+
}
4278+
}
4279+
4280+
impl PartialEq<Value> for str {
4281+
#[inline]
4282+
fn eq(&self, other: &Value) -> bool {
4283+
*other == *self
4284+
}
4285+
}
4286+
4287+
impl PartialEq<str> for Const {
4288+
#[inline]
4289+
fn eq(&self, other: &str) -> bool {
4290+
match self {
4291+
Self::Literal(s) => **s == *other,
4292+
}
4293+
}
4294+
}
4295+
4296+
impl PartialEq<Const> for str {
4297+
#[inline]
4298+
fn eq(&self, other: &Const) -> bool {
4299+
*other == *self
4300+
}
4301+
}

crates/forge_analyzer/src/interp.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,10 @@ impl<'cx, C: Runner<'cx>> Interp<'cx, C> {
795795
None => {
796796
if self.is_obj(varid) {
797797
Value::Object(varid)
798+
} else if let Some(defid) = self.body().get_defid_from_var(varid)
799+
&& let Some(val) = self.value_manager.defid_to_value.get(&defid)
800+
{
801+
val.clone()
798802
} else {
799803
Value::Unknown
800804
}
@@ -947,11 +951,13 @@ impl<'cx, C: Runner<'cx>> Interp<'cx, C> {
947951
let mut dataflow = C::Dataflow::with_interp(self);
948952
let mut worklist = WorkList::new();
949953

954+
// funcs then are pushed after
955+
worklist.push_front_blocks(self.env, func_def, self.call_all);
956+
957+
// global should be first
950958
for global_def in &self.env().global {
951959
worklist.push_front_blocks(self.env, *global_def, self.call_all);
952960
}
953-
954-
worklist.push_front_blocks(self.env, func_def, self.call_all);
955961
let old_body = self.curr_body.get();
956962
while let Some((def, block_id)) = worklist.pop_front() {
957963
let arguments = self.callstack_arguments.pop();

crates/forge_analyzer/src/runners.rs

Whitespace-only changes.

crates/forge_loader/src/manifest.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(dead_code, unused)]
12
use std::{
23
borrow::Borrow,
34
collections::{BTreeSet, HashSet},
@@ -165,6 +166,7 @@ struct ContentAction<'a> {
165166
#[serde(flatten, borrow)]
166167
common_keys: CommonKey<'a>,
167168
}
169+
168170
#[derive(Default, Debug, Clone, PartialEq, Eq, Deserialize)]
169171
struct ContentByLineItem<'a> {
170172
#[serde(flatten, borrow)]

0 commit comments

Comments
 (0)