mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-05-01 17:50:03 +00:00
Check source_file_path
to ensure it is valid (#421)
* Add new variant `BinstallError::DuplicateSourceFilePath` * Check `bin.source` in `collect_bin_files` * Add new variant `BinstallError::InvalidSourceFilePath` * Make sure generated source_file_path cannot access outside curdir * Add new variant `BinstallError::EmptySourceFilePath` * Ensure source_file_path is not empty Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
e034d69e12
commit
3da5cb9d9c
3 changed files with 72 additions and 2 deletions
|
@ -284,6 +284,33 @@ pub enum BinstallError {
|
|||
#[diagnostic(severity(error), code(binstall::cargo_manifest))]
|
||||
CargoTomlMissingPackage(CompactString),
|
||||
|
||||
/// bin-dir configuration provided generates duplicate source path.
|
||||
///
|
||||
/// - Code: `binstall::cargo_manifest`
|
||||
/// - Exit: 90
|
||||
#[error("bin-dir configuration provided generates duplicate source path: {path}")]
|
||||
#[diagnostic(severity(error), code(binstall::SourceFilePath))]
|
||||
DuplicateSourceFilePath { path: PathBuf },
|
||||
|
||||
/// bin-dir configuration provided generates source path outside
|
||||
/// of the temporary dir.
|
||||
///
|
||||
/// - Code: `binstall::cargo_manifest`
|
||||
/// - Exit: 91
|
||||
#[error(
|
||||
"bin-dir configuration provided generates source path outside of the temporary dir: {path}"
|
||||
)]
|
||||
#[diagnostic(severity(error), code(binstall::SourceFilePath))]
|
||||
InvalidSourceFilePath { path: PathBuf },
|
||||
|
||||
/// bin-dir configuration provided generates empty source path.
|
||||
///
|
||||
/// - Code: `binstall::cargo_manifest`
|
||||
/// - Exit: 92
|
||||
#[error("bin-dir configuration provided generates empty source path")]
|
||||
#[diagnostic(severity(error), code(binstall::SourceFilePath))]
|
||||
EmptySourceFilePath,
|
||||
|
||||
/// A wrapped error providing the context of which crate the error is about.
|
||||
#[error("for crate {crate_name}")]
|
||||
CrateContext {
|
||||
|
@ -319,6 +346,9 @@ impl BinstallError {
|
|||
NoViableTargets => 87,
|
||||
BinFileNotFound(_) => 88,
|
||||
CargoTomlMissingPackage(_) => 89,
|
||||
DuplicateSourceFilePath { .. } => 90,
|
||||
InvalidSourceFilePath { .. } => 91,
|
||||
EmptySourceFilePath => 92,
|
||||
CrateContext { error, .. } => error.exit_number(),
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue