呼び出されたときにファイルを削除する Web メソッドがあり、3 つのパラメーター (cNum、year、および fileName) を受け入れるとします。この方法の悪用について心配する必要がありますか。私が考えることができる唯一のことは..\..\..\
、削除をフォルダー構造のさらに上に移動するために使用することです。それを削除するのはかなり簡単なはずです。しかし、私が心配する必要があることは他にありますか?
[WebMethod(EnableSession = true,
Description = "Method for deleting files uploaded by customers")]
[ScriptMethod(ResponseFormat = ResponseFormat.Xml)]
public Boolean deleteCustFiles(string cNum, string year, string fileName)
{
try
{
if (String.IsNullOrEmpty(cNum)
|| String.IsNullOrEmpty(year)
|| String.IsNullOrEmpty(fileName))
throw new Exception();
string path = Server.MapPath(@"~\docs\custFiles\"
+ year + @"\"
+ cNum + @"\" + fileName);
File.Delete(path);
}
catch
{
throw new Exception("Unable to delete file");
}
return true;
}