Skip to content

Commit

Permalink
- расширена проверка локализаций в части встраивания таксономических …
Browse files Browse the repository at this point in the history
…полей (special thanks @Protenil).
  • Loading branch information
DmitryOffsec committed Jul 31, 2024
1 parent 2718ea6 commit a0b7c90
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 7 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.20 (Pre-Release)

- расширена проверка локализаций в части встраивания таксономических полей (special thanks @Protenil).

## 3.17.19 (Pre-Release)

- улучшена локализация (special thanks @feelstacy, @eugzolotukhin);
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.19",
"version": "3.17.20",
"repository": {
"type": "git",
"url": "https://github.com/Security-Experts-Community/vscode-xp"
Expand Down
25 changes: 21 additions & 4 deletions client/src/views/localization/checkLocalizationsCommand.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import * as fs from 'fs';
import * as path from 'path';
import * as vscode from 'vscode';

import { TestHelper } from '../../helpers/testHelper';
import { ContentItemStatus, RuleBaseItem } from '../../models/content/ruleBaseItem';
import { Configuration } from '../../models/configuration';
import { ContentItemStatus } from '../../models/content/ruleBaseItem';
import { DialogHelper } from '../../helpers/dialogHelper';
import { ContentTreeProvider } from '../contentTree/contentTreeProvider';
import { SiemjManager } from '../../models/siemj/siemjManager';
Expand Down Expand Up @@ -43,6 +41,13 @@ export class CheckLocalizationCommand extends ViewCommand {
return;
}

this.params.rule.getLocalizations().forEach(
(localization, index) => {
this.checkBalanceOfCurlyBraces(index, localization.getRuLocalizationText());
this.checkBalanceOfCurlyBraces(index, localization.getEnLocalizationText());
}
);

// Сбрасываем статус правила в исходный
this.params.rule.setStatus(ContentItemStatus.Default);
await ContentTreeProvider.refresh(this.params.rule);
Expand Down Expand Up @@ -91,11 +96,23 @@ export class CheckLocalizationCommand extends ViewCommand {
await FileSystemHelper.deleteAllSubDirectoriesAndFiles(this.params.tmpDirPath);
}
catch(error) {
Log.warn("Ошибка очистки временных файлов интеграционных тестов", error);
Log.warn("Error clearing temporary integration test files", error);
}
}
}

private checkBalanceOfCurlyBraces(localizationNumber: number, localization: string) {
const numberOfOpeningCurlyBrace = localization.match(/\{/g);
const numberOfClosingCurlyBrace = localization.match(/\}/g);
if(numberOfOpeningCurlyBrace && numberOfClosingCurlyBrace && numberOfOpeningCurlyBrace.length > numberOfClosingCurlyBrace.length) {
throw new XpException(`Ошибка использования полей таксономии в локализации №${localizationNumber + 1}, не все открывающиеся фигурные скобки имеют соответствующие закрывающиеся`);
}

if(numberOfOpeningCurlyBrace && numberOfClosingCurlyBrace && numberOfOpeningCurlyBrace.length < numberOfClosingCurlyBrace.length) {
throw new XpException(`Ошибка использования полей таксономии в локализации №${localizationNumber + 1}, не все закрывающиеся фигурные скобки имеют соответствующие открывающиеся`);
}
}

private async getLocalizationExamplesForCorrelation(): Promise<LocalizationExample[]> {
return await vscode.window.withProgress({
location: vscode.ProgressLocation.Notification,
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.19",
"version": "3.17.20",
"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.19",
"version": "3.17.20",
"author": "Dmitry Fedosov (@DmitryOffsec)",
"license": "MIT",
"engines": {
Expand Down

0 comments on commit a0b7c90

Please sign in to comment.