Skip to content

Commit

Permalink
- добавлена проверка корректности пути к правилу/тестам (special thanks
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryOffsec committed Jun 27, 2024
1 parent ed273a5 commit 210c2a5
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## 3.17.10 (Pre-Release)

- добавлена проверка корректности пути к правилу/тестам (special thanks @Bobyboba18).

## 3.17.9 (Pre-Release)

- добавлена поддержка работы с [недоверенным рабочим пространством](https://code.visualstudio.com/docs/editor/workspace-trust) (workspace). В этом случае расширение будет работать, но будет жаловаться на отсутствие расширения git, что будет замедлять выполнения тестов/корреляции файлов и событий и так далее;
Expand Down
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Language client",
"author": "Dmitry Fedosov (@DmitryOffsec)",
"license": "MIT",
"version": "3.17.9",
"version": "3.17.10",
"repository": {
"type": "git",
"url": "https://github.com/Security-Experts-Community/vscode-xp"
Expand Down
3 changes: 3 additions & 0 deletions client/src/models/siemj/siemjConfigBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,9 @@ out=${output}`;
* @returns путь к директории с временными файлами.
*/
public addTestsRun(testsRuleFullPath: string, tmpFilesPath?: string) : void {
if(!FileSystemHelper.isValidPath(testsRuleFullPath)) {
throw new XpException(this.config.getMessage('Error.InvalidPath', testsRuleFullPath));
}

const formulas = path.join('${output_folder}', this.config.getNormalizationsGraphFileName());
const enrules = path.join('${output_folder}', this.config.getEnrichmentsGraphFileName());
Expand Down
12 changes: 11 additions & 1 deletion client/src/models/siemj/siemjManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,13 @@ export class SiemjManager {
throw new FileSystemException(`Файл сырых событий '${rawEventsFilePath}' не существует`);
}

// Ограничения KBT
if(!FileSystemHelper.isValidPath(rawEventsFilePath)) {
throw new XpException(this.config.getMessage('Error.InvalidPath', rawEventsFilePath));
}

const contentFullPath = rule.getPackagePath(this.config);
if(!fs.existsSync(contentFullPath)) {
if(!FileSystemHelper.isValidPath(contentFullPath)) {
throw new FileSystemException(`Директория контента '${contentFullPath}' не существует`);
}

Expand Down Expand Up @@ -101,6 +106,11 @@ export class SiemjManager {
throw new FileSystemException(`Файл сырых событий '${rawEventsFilePath}' не существует`);
}

// Ограничения KBT
if(!FileSystemHelper.isValidPath(rawEventsFilePath)) {
throw new XpException(`Обнаружены недопустимые символы в пути ${rawEventsFilePath}. Исправьте путь и повторите`);
}

const contentFullPath = rule.getPackagePath(this.config);
if(!fs.existsSync(contentFullPath)) {
throw new FileSystemException(`Директория контента '${contentFullPath}' не существует`);
Expand Down
1 change: 1 addition & 0 deletions l10n/xp.nls.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"Error.IncorrectOutputDirectoryPath": "Failed to create an output directory on the path '{0}'. Set the correct path to the output directory [in the settings](command:workbench.action.openSettings?['xpConfig.outputDirectoryPath'])",
"Error.CommonBuilding": "The operation failed. Fix [file errors](command:workbench.action.showErrorsWarnings). If there are no errors, check the [output](command:xp.commonCommands.showOutputChannel)",
"Error.LocalizationBuilding": "Localization could not be compiled. Fix [file errors](command:workbench.action.showErrorsWarnings). If there are no errors, check the [output](command:xp.commonCommands.showOutputChannel)",
"Error.InvalidPath": "Invalid characters were found in the path {0}. Correct the path and repeat",

"View.ObjectTree.Message.TheKnowledgeBaseIsNotInitialized": "The knowledge base was not found. Create standard folders for {0}?",
"View.ObjectTree.Message.NeedToOpenKnowledgeBase": "To run the command, you must [open the knowledge base](command:xp.contentTree.openKnowledgebaseCommand)",
Expand Down
1 change: 1 addition & 0 deletions l10n/xp.nls.ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"Error.IncorrectOutputDirectoryPath": "Не удалось создать папку в {0}. Укажите корректный путь [в параметре](command:workbench.action.openSettings?['xpConfig.outputDirectoryPath'])",
"Error.CommonBuilding": "Не удалось выполнить операцию. Исправьте [ошибки в файлах](command:workbench.action.showErrorsWarnings). Если ошибок нет, проверьте [выходные данные](command:xp.commonCommands.showOutputChannel)",
"Error.LocalizationBuilding": "Не удалось скомпилировать правила локализации. Исправьте [ошибки в файлах](command:workbench.action.showErrorsWarnings). Если ошибок нет, проверьте [выходные данные](command:xp.commonCommands.showOutputChannel)",
"Error.InvalidPath": "Обнаружены недопустимые символы в пути {0}. Исправьте путь и повторите",

"View.ObjectTree.Message.TheKnowledgeBaseIsNotInitialized": "База знаний не найдена. Создать стандартные папки для продукта {0}?",
"View.ObjectTree.Message.NeedToOpenKnowledgeBase": "Для выполнения команды нужно [открыть базу знаний](command:xp.contentTree.openKnowledgebaseCommand)",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"author": "Dmitry Fedosov (@DmitryOffsec)",
"icon": "resources/xp.png",
"license": "MIT",
"version": "3.17.9",
"version": "3.17.10",
"repository": {
"type": "git",
"url": "https://github.com/Security-Experts-Community/vscode-xp"
Expand Down
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "server",
"description": "Language server",
"version": "3.17.9",
"version": "3.17.10",
"author": "Dmitry Fedosov (@DmitryOffsec)",
"license": "MIT",
"engines": {
Expand Down

0 comments on commit 210c2a5

Please sign in to comment.