如果我有一个在调用时删除文件的 Web 方法,并且它接受三个参数(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;
}