예제 #1
0
        private async Task CheckSize(CheckFileLimitBo bo)
        {
            var fileLimit = await this._repository.Get(bo.AppId);

            if (bo.Content.Length > fileLimit.MaxSize)
            {
                throw new FileTooLargeException(fileLimit.MaxSize);
            }
        }
예제 #2
0
        private NameAndContent[] ExpandFile(CheckFileLimitBo bo)
        {
            // how deep?
            //throw new NotImplementedException();
            var result = new NameAndContent();

            result.name    = bo.Name;
            result.content = bo.Content;
            return(new NameAndContent[] { result });
        }
        private void CheckBlackList(CheckFileLimitBo bo)
        {
            var blackList = _configService.GetJson <string[]>("FileBlackList");
            var files     = ExpandFile(bo);

            // throw exception if not all files pass test
            if (!files.All(f => TestFile(f, blackList)))
            {
                throw new FileNotAllowedException();
            }
        }
예제 #4
0
        private async Task CheckBlackList(CheckFileLimitBo bo)
        {
            var blackList = await _configService.GetJson <string[]>("FileBlackList");

            var files = ExpandFile(bo);
            FileLegitimacyChecker fileLegitimacyChecker = new FileLegitimacyChecker(blackList);

            // throw exception if not all files pass test
            if (!files.All(f => fileLegitimacyChecker.FileLegitimacyCheck(f.name, f.content)))
            {
                throw new FileNotAllowedException();
            }
            return;
        }
예제 #5
0
 public async Task Check(CheckFileLimitBo bo)
 {
     await CheckSize(bo);
     await CheckBlackList(bo);
 }
 private NameAndContent[] ExpandFile(CheckFileLimitBo bo)
 {
     // how deep?
     throw new NotImplementedException();
 }
        private void CheckSize(CheckFileLimitBo bo)
        {
            var maxSize = this._repository.Get(bo.AppId).MaxSize;

            throw new NotImplementedException();
        }
 public void Check(CheckFileLimitBo bo)
 {
     throw new System.NotImplementedException();
 }