Menu
Is free
registration
home  /  Education/ 1s 8 safe mode is set. Opening external processing programmatically

1c 8 is set to safe mode. Opening external processing programmatically

Programmatic discovery external processing is carried out using the ExternalProcessing global context object, which has the type ExternalProcessingManager... For each operating mode of the 1C platform (normal application mode and managed application) uses various object methods to work with external processing.

Start external processing in normal application mode

V normal application you must use the Create () method of the ExternalProcessing object, which is passed the full name of the external processing file. The method returns an object of type External Processing, this object is the external processing being opened. If you need to open an external processing form, then call the GetForm () method on the resulting object, which will return the main form, and then call the Open () method to open it.


Processing = ExternalProcessing.Create (FullFileName);
Processing.GetForm (). Open ();

In external processors, the main form must always be a regular form, and the managed form must always be an additional one, otherwise the GetForm () method will not work in the normal application mode.

Starting external processing in managed application mode

In the mode managed forms the division of the algorithm according to the execution context appears. On the client, we get binary data by the full name of the external processing file. We transfer the received binary data to the server and put it in temporary storage. Next, you need to call the Connect () method of the ExternalProcessing object, to which the address to the temporary storage is passed. The method returns the name of the connected external processing. We return the name of the external processing to the client, form a string path to the processing form and use the OpenForm () method to open the external processing form.

&On server
GetExternalProcessingName Function (BinaryData)
AddressToTemporaryStorage = PutToTemporalStore (BinaryData);
Return ExternalProcessing.Connect (AddressInTemporaryStorage);
EndFunction

& OnClient
FullFileName = ""; // Full name of the external processing file.
FileData = New BinaryData (FullFileName);
ExternalProcessingName = GetExternalProcessingName (FileData);
OpenForm ("ExternalProcessing." + ExternalProcessingName + ".Form");

Safe mode for external treatments

The Create () and Connect () methods of the ExternalProcessing object have an input parameter SafeMode - a sign of connecting external processing in safe mode. If the parameter is not specified, the connection will be made in safe mode.
Safe mode work is designed to protect the system from executing "unreliable" program code on the server. Potential hazards are external treatments or program code user-entered for use in the Execute () and Calculate () methods.
Safe mode has the following restrictions:
  • privileged mode is canceled if it was set;
  • attempts to enter privileged mode are ignored;
  • operations with COM objects are prohibited;
  • loading and connecting external components is prohibited;
  • denied access to file system(except for temporary files);
  • Internet access is denied.
Processings opened interactively are not performed in safe mode, therefore it is recommended to implement a mechanism for opening external processors in safe mode, as well as to prevent the user from interactively opening external processors at the level of rights.
To prohibit the interactive opening of processing, in all roles assigned to the user, you must remove the "Open external processing interactively" right (see Figure 1).
Figure 1. Rights of interactive opening of external processings / reports
The Open External Processors interactively right does not affect the ExternalProcessing object in any way.

Opening external reports programmatically, similar to external processors, you should only use the External Reports global context object, which has the type ExternalReportManager.

The fact is that when using the client-server version of 1C operation, external processing / reports are opened in safe mode, in which the use of privileged mode is prohibited. And the privileged mode is used very often in typical configurations: formation printed forms, various official checks (registration of exchanges), etc. As a result, even using a regular report on the ACS without a form (by default, the general form "Report Form" is used) and keeping custom settings report (to the corresponding reference), you will receive an error about insufficient access rights to various constants and session parameters used for service purposes after the line SetPrivilegedMode (True);

The "correct" solution would be to connect external processors and reports through the mechanisms of the BSP "Additional reports and processing" with disabling the safe mode or adding permissions (in my opinion, with BSP versions 2.2.2.1). But if for some reason it is necessary to use exactly external files reports / processing, you can configure a cluster security profile that is used as a safe mode security profile for a specific infobase.

I would like to note right away that this option is not preferable, but due to various circumstances, it can be used in such a simplified form. For example, I have several bases in different cities, a common local sit down with strictly limited rights, closed USB, etc., somewhere I use Accounting 2.0, and somewhere 3.0, I make almost all reports using ACS without forms, so that they opened in both versions. Serve all these reports for different versions and different bases is a laborious and hopeless business, tk. plans include a transition to a single configuration and base ...

We create a profile.
In the cluster console, create a security profile in which we set flags "Can be used as a safe mode security profile" and "under" Allowed full access:" "to privileged mode".

In many cases of using reports and simple treatments this method will be applicable. For more complex situations, it makes no sense to describe the process, because it is stated in the documentation (the ability to customize security profiles for specific external files by specifying its hash, etc.).

P.S. I thought that security profiles function only when using licenses for the platform and server of the CORP level, but this functionality is also fulfilled on the 1C: Enterprise 8.3 platform (conditionally, you can call PROF by analogy with typical configurations Basic / PROF / CORP)

With the release of platform 8.3.9.2033 appeared new mechanism "Protection against dangerous actions".

Thanks to this innovation, 1C -ka now began to swear at the opening of processing (and not only):

Security warning

Opens "My external processing" from the file "My_External_Processing.epf"

It is recommended to pay attention to the source from which the this file... If there is no agreement with the source on the development additional modules, or there are doubts about the contents of the file, then it is not recommended to open it, as this may harm your computer and data.

Do you want to allow this file to be opened?

So 1C decided to fight against malicious code!

Where will this " malicious code"The enterprise is still a mystery)

Potentially dangerous actions included:

  • Loading an external report, processing or expanding the configuration.
  • Load or update configuration / extension.
  • Access from an external report / processing or extension to the following features:
  • Operating system command execution.
  • User management (recording or deleting information about an infobase user).
  • Calling the Connect () method of the external processors (reports) manager.
  • Calling the ConfigurationExtension.Write () method.
  • Working with COM objects.

How can this "miracle" be turned off?

To do this, you need to run 1C Enterprise in the configurator mode.
Select the "Administration" - "Users" menu.
In the opened window of our users, you need to open the user settings window and on the "Basic" tab remove the checkbox "Protection against dangerous actions"

There are other ways to turn this off:

The ability to specify a list of infobases has been implemented, when working with which protection against dangerous actions will be disabled.
Per this function the DisableUnsafeActionProtection parameter in the conf.cfg file is responsible, which allows you to disable the protection mechanism against dangerous actions for all users of certain infobases whose connection strings satisfy the masks specified in the DisableUnsafeActionProtection parameter.

In this parameter, you can specify several masks separated by the ";" symbol, for example:

DisableUnsafeActionProtection = test _. *; Stage _. *;

In addition, protection against dangerous user actions can be disabled programmatically, for which there are the following parameters and properties:

  • Parameter Protection from dangerous actions of methods Connect () managers of external processing (reports)
  • The HazardousActionProtection property of theConfigurationExtension object before calling the Write () method of this object.

Checking the need to use protection against dangerous actions is performed in the following order:

1. If the "Protection against dangerous actions" checkbox is cleared for the current user, then the protection is considered disabled.

2. If the connection string with information base matches one of the templates specified in the DisableUnsafeActionProtection parameter of the conf.cfg file, the protection is considered disabled.

3. If protection is explicitly disabled using the AntiDangerousActions parameter of an external processing or report.

4. If protection is explicitly disabled using the AntiDangerousActions extension property.

Print (Ctrl + P)

Configuration objects

If you need to use "unreliable" program code on the server: external processing or program code entered by the user for use in the Execute () and Calculate () methods, you can use the safe mode of operation.

In safe mode:

  • Privileged mode canceled.
  • Entering privileged mode ignored.
  • Are prohibited operations leading to the use of external funds in relation to the 1C: Enterprise platform (including non-blocking analogues of the above methods):
  • COM mechanisms:
    • COM Object ();
    • GetCOMObject ();
    • Wrapper HTMLDocument.GetCOMObject ().
  • Loading external components:
    • Load ExternalComponent ();
    • Connect External Component ().
  • File system access:
    • ValueInFile ();
    • CopyFile ();
    • CombineFiles ();
    • MoveFile ();
    • SplitFile ();
    • CreateDirectory ();
    • DeleteFiles ();
    • New File;
    • New xBase;
    • HTMLWrite.OpenFile ();
    • Reading HTML.OpenFile ();
    • Read XML.OpenFile ();
    • XMLWrite.OpenFile ();
    • ReadingFastInfoset.OpenFile ();
    • WriteFastInfoset.OpenFile ();
    • CanonicalXMLWriter.OpenFile ();
    • ConversionXSL.LoadFromFile ();
    • WriteZipFile.Open ();
    • Reading a ZipFile.Open ();
    • NewTextReader (), if the first parameter is a string;
    • ReadText.Open () if the first parameter is a string;
    • NewWriteText (), if the first parameter is a string;
    • WriteText.Open (), if the first parameter is a string;
    • NewExtractText ();
    • changing the RetrieveText.FileName property;
    • ExtractText.Write ();
    • New Picture (), if the first parameter is a string;
    • Picture.Write ();
    • New BinaryData ();
    • BinaryData.Write ();
    • NewDataWrite (), if the first parameter is a string;
    • NewReaderData (), there is the first parameter - a string;
    • all methods of the FileStreamManager object;
    • New FileStream ();
    • FormattedDocument.Write ();
    • GeographicSchema.Read ();
    • GeographicSchema.Record ();
    • GeographicSchema.Print ();
    • TabularDocument.Read ();
    • TabularDocument.Write ();
    • TabularDocument.Print (); GraphicSchema.Read ();
    • GraphicalScheme.Write ();
    • GraphicalScheme.Print ();
    • TextDocument.Read ();
    • TextDocument.Write ().
  • Internet access:
    • New InternetConnection,
    • New Internet Mail,
    • New InternetProxy,
    • New HTTPConnection,
    • New FTPConnection.

ATTENTION! Throws an exception when performing prohibited operations at runtime.

Note. External reports and processing opened using the File - Open menu are executed in safe mode if the user does not have administrative access rights.

The number of failures must be the same as the number of shutdowns. However, if a safe mode was turned on (once or more) within a procedure or function, but it was not turned off, the system will automatically shut down as many times as there were incomplete turn-ons in the procedure or function to be abandoned.

If a procedure or function calls a method Set Safe Mode (False) done more than method calls Set Safe Mode (True) then an exception will be thrown.

Safe mode software setting may be required when the configuration developer assumes the use of third-party (in relation to the configuration) program code, the reliability of which the developer cannot guarantee. An example of such code is the execution of the Execute () and Compute () methods in cases where the executable code is obtained from outside world... In this case, it is good practice to set safe mode before executing these methods:

// A program code is generated that should be executed // It is possible that the code is loaded from external sources// or manually entered ExecutableCode = GetExecutableCodeFrom the OutsideWorld (); // Enable Safe Mode Set Safe Mode (True); // Execute potentially dangerous code Execute (Executable Code); // Turn off Safe Mode Set Safe Mode (False);

In some cases, safe mode settings may conflict with privileged mode settings. An example of such a conflict is posting a document that has the Privileged mode on posting property set from embedded code that runs in safe mode. In this case, privileged mode is disabled, and attempts to enable it are ignored. As a result, code in the embedded language that "relies" on the enabled privileged mode "collides" with its absence, which leads to errors with non-obvious reasons. To prevent such a situation, the 1C: Enterprise system automatically disables the safe mode for event handlers that are available in the object module or manager module, provided that the executable code in the embedded language is not located in the configuration extension. Such handlers are marked in a special way in the syntax helper.

It also provides the option to disable safe mode from the embedded language (if the program code from which the disconnect is attempted is not in a configuration extension). To disable safe mode, use the method Set Safe Mode Disable ()... Check that safe mode is in this moment disabled (automatically or by calling a method), you can use the method GetDisableSafeMode ().

Within a single embedded language method, there can be no more than one nesting level of setting safe mode (by calling the SetSafeMode () method) and setting to disable safe mode (automatically for the duration of the event handlers of metadata objects or by calling the SetDisableSafeMode () method). When trying to increase nesting, an exception is thrown:

// Correct use Procedure ProcedureName () SetSafeModeDisable (True); Set Safe Mode (True); Set Safe Mode (False); Set Safe Mode Disable (False); EndProcedure // Incorrect use Procedure ProcedureName () SetSafeModeDisable (True); Set Safe Mode (True); Set Safe Mode Disable (False); // Exception EndProcedure Procedure ProcedureName () SetSafeMode (True); Set Safe Mode Disable (False); // Exception EndProcedure