Skip to content

Commit

Permalink
chore: bump deps
Browse files Browse the repository at this point in the history
  • Loading branch information
jwong101 committed May 20, 2024
1 parent 326b371 commit 96b1345
Show file tree
Hide file tree
Showing 11 changed files with 508 additions and 551 deletions.
962 changes: 464 additions & 498 deletions Cargo.lock

Large diffs are not rendered by default.

37 changes: 15 additions & 22 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,20 @@ edition = "2021"
license = "MIT OR Apache-2.0"

[workspace.dependencies]
clap = { version = "4.4.8", features = ["derive", "wrap_help"] }
fixedbitset = "0.4.2"
itertools = "0.12.0"
miette = { version = "7.1.0", features = ["fancy"] }
num-bigint = { version = "0.4.3" }
serde = { version = "1.0.192", features = ["derive"] }
serde_json = "1.0.108"
serde_yaml = "0.9.27"
petgraph = "0.6.2"
clap = { version = "4.5.4", features = ["derive", "wrap_help"] }
itertools = "0.12.1"
num-bigint = { version = "0.4.4" }
serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.115"
serde_yaml = "0.9.34"
petgraph = "0.6.4"
pretty_assertions = "1.4.0"
indexmap = { version = "2.1.0", features = ["std"] }
once_cell = "1.17.0"
regex = "1.7.1"
indexmap = { version = "2.2.6", features = ["std"] }
once_cell = "1.19.0"
regex = "1.10.4"
rustc-hash = "1.1.0"
im-rc = "15.1.0"
smallvec = { version = "1.11.2", features = ["union", "const_new"] }
swc_core = { version = "0.90.9", features = [
smallvec = { version = "1.13.2", features = ["union", "const_new"] }
swc_core = { version = "0.90.26", features = [
"common",
"common_sourcemap",
"ecma_visit_path",
Expand All @@ -38,16 +35,16 @@ swc_core = { version = "0.90.9", features = [
"ecma_transforms_typescript",
"ecma_parser_typescript",
] }
thiserror = "1.0.50"
time = { version = "0.3.30", features = [
thiserror = "1.0.58"
time = { version = "0.3.34", features = [
"local-offset",
"serde-human-readable",
] }
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
tracing-tree = "0.3.0"
typed-index-collections = "3.1.0"
walkdir = "2.3.2"
walkdir = "2.5.0"
forge_loader = { path = "crates/forge_loader" }
forge_analyzer = { path = "crates/forge_analyzer" }
forge_file_resolver = { path = "crates/forge_file_resolver" }
Expand All @@ -63,10 +60,6 @@ unsafe_op_in_unsafe_fn = "deny"
[workspace.lints.clippy]
too_many_arguments = "allow"

# enable a small amount of optimization in debug mode
[profile.dev]
opt-level = 1

# enable full optimization for dependencies
[profile.dev.package."*"]
opt-level = 3
3 changes: 0 additions & 3 deletions crates/forge_analyzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,12 @@ workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
fixedbitset.workspace = true
forge_file_resolver.workspace = true
forge_utils.workspace = true
forge_loader.workspace = true
forge_permission_resolver.workspace = true
itertools.workspace = true
im-rc.workspace = true
num-bigint.workspace = true
once_cell.workspace = true
petgraph.workspace = true
regex.workspace = true
serde_json.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/forge_analyzer/src/ctx.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::cell::OnceCell;
use std::path::Path;
use std::{borrow::Borrow, hash::Hash, path::PathBuf};

use forge_file_resolver::{FileResolver, ForgeResolver};
use forge_utils::create_newtype;
use forge_utils::FxHashMap;
use once_cell::unsync::OnceCell;
use petgraph::prelude::NodeIndex;
use petgraph::stable_graph::DefaultIx;
use smallvec::smallvec;
Expand Down
18 changes: 13 additions & 5 deletions crates/forge_analyzer/src/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -853,13 +853,21 @@ enum ApiCallKind {
}

fn classify_api_call(expr: &Expr) -> ApiCallKind {
use once_cell::sync::Lazy;
use regex::Regex;
use std::cell::OnceCell;

// FIXME: this should be done as a dataflow analysis instead of on the AST.
static TRIVIAL: Lazy<Regex> = Lazy::new(|| {
Regex::new(r"user|instance|avatar|license|preferences|server[iI]nfo").unwrap()
});
fn trivial_regex(route: &str) -> bool {
thread_local! {
static TRIVIAL: OnceCell<Regex> = const { OnceCell::new() }
}
TRIVIAL.with(move |r| {
r.get_or_init(|| {
Regex::new(r"user|instance|avatar|license|preferences|server[iI]nfo").unwrap()
})
.is_match(route)
})
}

#[derive(Default)]
struct ApiCallClassifier {
Expand All @@ -870,7 +878,7 @@ fn classify_api_call(expr: &Expr) -> ApiCallKind {
fn check(&mut self, name: &str) {
if name.contains("permission") {
self.kind = self.kind.max(ApiCallKind::Authorize);
} else if TRIVIAL.is_match(name) || name.contains("group") {
} else if trivial_regex(name) || name.contains("group") {
self.kind = self.kind.max(ApiCallKind::Trivial);
} else if name == "/rest/api/3/field" || name == "/rest/api/2/field" {
self.kind = ApiCallKind::Fields;
Expand Down
2 changes: 1 addition & 1 deletion crates/forge_analyzer/src/ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

use core::fmt;
use std::array;
use std::cell::OnceCell;
use std::collections::BTreeSet;
use std::collections::HashMap;
use std::hash;
Expand All @@ -15,7 +16,6 @@ use std::slice;

use forge_utils::create_newtype;
use forge_utils::FxHashMap;
use once_cell::unsync::OnceCell;
use smallvec::smallvec;
use smallvec::smallvec_inline;
use smallvec::SmallVec;
Expand Down
1 change: 0 additions & 1 deletion crates/forge_loader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ workspace = true
[dependencies]
forge_utils.workspace = true
itertools.workspace = true
miette.workspace = true
serde.workspace = true
serde_json.workspace = true
serde_yaml.workspace = true
Expand Down
7 changes: 1 addition & 6 deletions crates/forge_loader/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
use std::path::PathBuf;

use miette::Diagnostic;
use thiserror::Error;

#[derive(Debug, Diagnostic, Error)]
#[derive(Debug, Error)]
pub enum Error {
#[error("could not find file at {path} for function `{function}`")]
#[diagnostic(help(
"try adding a file with a .jsx,.js,.tx,.tsx extension in the src directory"
))]
FileNotFound { function: String, path: PathBuf },
#[error("function handler {0} should contain a period")]
#[diagnostic(help("try adding a period separating the file name and function name"))]
InvalidFuncHandler(String),
}

Expand Down
2 changes: 1 addition & 1 deletion crates/forge_permission_resolver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ serde.workspace = true
serde_json.workspace = true
tracing.workspace = true
regex.workspace = true
ureq = { version = "2.7.1", features = ["json", "charset"] }
ureq = { version = "2.9.6", features = ["json", "charset"] }


[dev-dependencies]
Expand Down
1 change: 0 additions & 1 deletion crates/fsrt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ forge_analyzer.workspace = true
forge_file_resolver.workspace = true
forge_loader.workspace = true
forge_permission_resolver.workspace = true
miette.workspace = true
rustc-hash.workspace = true
serde.workspace = true
serde_json.workspace = true
Expand Down
24 changes: 12 additions & 12 deletions crates/fsrt/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use forge_permission_resolver::permissions_resolver::{
get_permission_resolver_confluence, get_permission_resolver_jira,
};

use miette::Result;
use std::{
collections::HashSet,
fmt, fs,
Expand All @@ -32,11 +31,11 @@ use forge_analyzer::{
reporter::{Report, Reporter},
resolver::resolve_calls,
};
use miette::IntoDiagnostic;

use crate::forge_project::{ForgeProjectFromDir, ForgeProjectTrait};
use forge_loader::manifest::Entrypoint;
use walkdir::WalkDir;
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;

#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
Expand Down Expand Up @@ -105,6 +104,8 @@ impl fmt::Display for Error {
}
}

impl std::error::Error for Error {}

fn is_js_file<P: AsRef<Path>>(path: P) -> bool {
matches!(
path.as_ref().extension().map(|s| s.as_bytes()),
Expand All @@ -128,7 +129,7 @@ pub(crate) fn scan_directory<'a>(
dir: PathBuf,
opts: &Args,
project: impl ForgeProjectTrait<'a> + std::fmt::Debug,
) -> Result<Report, Error> {
) -> Result<Report> {
let paths = project.get_paths();
let manifest = project.get_manifest();
let mut proj = project.with_files_and_sourceroot(Path::new("src"), paths.clone(), vec![]);
Expand All @@ -147,7 +148,7 @@ pub(crate) fn scan_directory<'a>(

if transpiled_async {
warn!("Unable to scan due to transpiled async");
return Err(Error::TranspiledAsyncError);
Err(Error::TranspiledAsyncError)?;
}

let requested_permissions = manifest.permissions;
Expand All @@ -173,12 +174,11 @@ pub(crate) fn scan_directory<'a>(
proj.add_funcs(funcrefs);
resolve_calls(&mut proj.ctx);
if let Some(func) = opts.dump_ir.as_ref() {
let mut lock = std::io::stdout().lock();
proj.env.dump_function(&mut lock, func);
return Err(Error::TranspiledAsyncError);
proj.env.dump_function(&mut std::io::stdout().lock(), func);
std::process::exit(0);
}

let permissions = Vec::from_iter(permissions_declared.iter().cloned());
let permissions = permissions_declared.into_iter().collect::<Vec<_>>();

let (jira_permission_resolver, jira_regex_map) = get_permission_resolver_jira();
let (confluence_permission_resolver, confluence_regex_map) =
Expand Down Expand Up @@ -233,7 +233,7 @@ pub(crate) fn scan_directory<'a>(
&proj.env,
false,
true,
permissions.clone(),
permissions,
&jira_permission_resolver,
&jira_regex_map,
&confluence_permission_resolver,
Expand Down Expand Up @@ -363,7 +363,7 @@ fn main() -> Result<()> {
}
debug!(?manifest_file);

let manifest_text = fs::read_to_string(&manifest_file).into_diagnostic()?;
let manifest_text = fs::read_to_string(&manifest_file)?;

let forge_project_from_dir = ForgeProjectFromDir {
dir: dir.clone(),
Expand All @@ -374,11 +374,11 @@ fn main() -> Result<()> {
let reporter_result = scan_directory(dir, &args, forge_project_from_dir);
match reporter_result {
Result::Ok(report) => {
let report = serde_json::to_string(&report).into_diagnostic().unwrap();
let report = serde_json::to_string(&report)?;
debug!("On the debug layer: Writing Report");
match &args.out {
Some(path) => {
let _ = fs::write(path, report.clone()).into_diagnostic();
fs::write(path, &*report)?;
}
None => println!("{report}"),
}
Expand Down

0 comments on commit 96b1345

Please sign in to comment.