From 57c03a88086ce6dcbd62cbd60e9e52fed1a89f49 Mon Sep 17 00:00:00 2001 From: orbisai0security Date: Wed, 29 Apr 2026 15:54:02 +0000 Subject: [PATCH] fix: V-001 security vulnerability Automated security fix generated by Orbis Security AI --- forc/src/cli/commands/template.rs | 8 ++++++++ forc/src/ops/forc_template.rs | 9 ++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/forc/src/cli/commands/template.rs b/forc/src/cli/commands/template.rs index 10a9d905639..7f9db2c0bd5 100644 --- a/forc/src/cli/commands/template.rs +++ b/forc/src/cli/commands/template.rs @@ -22,6 +22,14 @@ pub struct Command { /// The name of the project that will be created pub project_name: String, + + /// A git tag to use for the template, e.g. `v0.1.0`. + #[clap(long)] + pub tag: Option, + + /// A specific git revision (commit hash) to use for the template. + #[clap(long)] + pub rev: Option, } pub(crate) fn exec(command: Command) -> ForcResult<()> { diff --git a/forc/src/ops/forc_template.rs b/forc/src/ops/forc_template.rs index 0304a9d298a..551bc2f07b4 100644 --- a/forc/src/ops/forc_template.rs +++ b/forc/src/ops/forc_template.rs @@ -21,9 +21,16 @@ pub fn init(command: TemplateCommand) -> Result<()> { .clone() .unwrap_or_else(|| format!("{}-template-source", command.project_name)); + let reference = if let Some(rev) = &command.rev { + source::git::Reference::Rev(rev.clone()) + } else if let Some(tag) = &command.tag { + source::git::Reference::Tag(tag.clone()) + } else { + source::git::Reference::DefaultBranch + }; let source = source::git::Source { repo: Url::from_str(&command.url)?, - reference: source::git::Reference::DefaultBranch, + reference, }; let current_dir = &env::current_dir()?;