KasperskyOS Community Edition 1.3

Extension functions

The extension automatically detects a KasperskyOS project in the open workspace and starts. The detection parameter is the presence of the .vscode/kos_project.json file or einit directory in the workspace. If the extension has not automatically activated in the directory but you are certain that it is a KasperskyOS project, run the command KOS: Activate extension in this directory. This command activates the extension and creates an empty .vscode/kos_project.json file in the project directory. To cancel manual activation, delete this file.

After startup, the extension adds the following buttons to the lower panel of the Visual Studio Code editor:

  • lower_panel_select_target – select the build target.
  • lower_panel_run – start the project in QEMU.
  • lower_panel_run_with_debug – start the selected target with debugging.
  • lower_panel_build – build all targets.
  • lower_panel_build_user_target – build the selected target.
  • lower_panel_clean – clear the build directory.
  • lower_panel_build_type – switch the build type.
  • lower_panel_build_with_tests – enable/disable the project build with tests.
  • lower_panel_build_target – select the target platform for the build.
  • lower_panel_select_device – select the device or QEMU emulator.
  • vscode_sdk_version – display the SDK version.

Functions that provide buttons can also be called from the command line of the code editor, which can be opened by pressing F1. All commands have the KOS: prefix.

Working with a basic KasperskyOS image

The extension lets you avoid having to completely build a KasperskyOS-based solution after making changes to application code. Instead, you can use the following scenario:

  1. Running a basic KasperskyOS-based solution image, included in the SDK, in the QEMU emulator. The basic image contains all the system programs required to run and debug programs packaged in KPA packages.
  2. Build an application and package it into a KPA package. You must use the CMake commands of the kpa library to pack a program into a KPA package.
  3. Install a program from a KPA package into the solution image that was run at step 1 and start it under KasperskyOS.
  4. Make changes to the application code.
  5. Repeat steps 2–5.
  6. With the extension, you can also debug a program that is running in a basic KasperskyOS image. For more details, refer to Debugging programs that are part of a KPA package.

Create a basic solution security policy description

The extension lets you automatically create basic solution security policy descriptions for a project.

To create a basic security policy description:

  1. Make sure that the KasperskyOS SDK Extension is installed and active.
  2. Press F1.
  3. Run the command KOS: Generate policy file for current project.
  4. Select the type of basic policy description that you want to create:
    • Grant all permissions: create a basic solution security policy description that allows all interactions between different processes of any class and between these processes and the KasperskyOS kernel, and that also allows any process to initialize the startup of processes.
    • Grant necessary permissions: create a basic solution security policy description that allows all interactions between different processes of any class and between these processes and the KasperskyOS kernel, and that also determines the necessary permissions for initializing the startup of processes based on the init.yaml.in file within the project.
  5. Enter the file name for saving the created security policy description.

These policies can be used only as stubs during the early stages of development of a KasperskyOS-based solution so that the Kaspersky Security Module does not interfere with interactions. It would be unacceptable to apply such policies in a real-world KasperskyOS-based solution.

Running tests

After the extension is activated, the Testing tab (left_panel_testing) appears on the side panel of Visual Studio Code. When you select the Testing tab, the code editor window displays a tree of tests created using the Google Test library and found in files in the test/ directory.

To run the tests, tap the run_tests button. All detected tests are run by default. However, you can select specific tests on the tabs containing the source code of the tests, or you can select specific groups of tests by selecting them from the tree of all tests. You can only run tests that are added to CMakeLists.txt files for building programs using the kl_kos_add_small_test() or generate_kos_test() CMake commands from the TestGenerator CMake library included in the SDK.

The test results and log files are located in the directory <build_directory>/bin/tests/output.

Starting solution security policy tests

The extension lets you run solution security policy tests for a project if they were created based on the solution security policy description.

To build and run solution security policy tests:

  1. Make sure that the solution security policy description contains the solution security policy tests.
  2. Make sure that the CMake commands for building solution security policy tests have been added to one of the CMakeLists.txt files of the project.
  3. Make sure that the KasperskyOS SDK Extension is installed and active.
  4. Build all targets by clicking the lower_panel_build button in the lower panel.
  5. Click the build target selection button lower_panel_select_target and select the target named kos-qemu-image-PalTest<N>-sim (N refers to the PSL file index within the list of PSL files containing solution security policy tests).
  6. Click the lower_panel_build_user_target button to build the selected target.

In this section

Starting a basic KasperskyOS-based solution image

Building programs in Visual Studio Code

Starting programs in a basic solution image

Debugging a program that is part of a KPA package