Computers Windows Internet

How to disable safe mode in 1s 8.3. Pavel is clean. Safe mode for external treatments

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: the formation of printed forms, various service checks (registration of exchanges), etc. As a result, even using a regular report on the ACS without a form (by default, the general "Report Form" form is used) and saving the custom report settings (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, from the BSP version 2.2.2.1). But if for some reason it is necessary to use exactly external files reports / processing, you can configure the cluster security profile used as the safe mode security profile for a specific information base.

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 processing, 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)

Print (Ctrl + P)

Configuration objects

If it is necessary to use "unreliable" program code on the server: external processing or program code entered by the user for use in the Run () and Evaluate () methods, you can use 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 ().
  • Access to file system:
    • 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.

Setting the safe mode programmatically 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 the 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 entered manually ExecutableCode = GetExecutiveCodeFrom the ExternalWorld (); // 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 cannot be more than one nesting level for setting safe mode (by calling the SetSafeMode () method) and setting to disable safe mode (automatically for the duration of the metadata object event handlers 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

External processing is programmatically opened 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 mode), various object methods are used to work with external processing.

Start external processing in normal application mode

In a typical 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 managed forms mode, a split of the algorithm by 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 danger is external processing or program code entered by the user 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;
  • access to the file system is denied (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.