Why am I getting a security warning message "This file contains potentially dangerous dynamic content" in this construct

Finally, I can play this message, which I get from time to time.

This is in V8.04, on windows 7.

During the attempts, I discovered how to get Mathematica to generate the above message when I open the laptop with Manipulate in it.

The error message screen appears first:

enter image description here

Now I click on “turn on the speaker” and everything looks good. But every time I open the laptop again, I get a message again. (You must close M and start again, and then open the laptop to see the message).

Therefore, I do not understand this warning message and why it appears, and what I need to change in the code in order to delete it.

Code to create it:

Manipulate[ DynamicModule[{p}, p["x"] = 0; Row[{Dynamic[ Refresh[p["x"]++; Row[{"p[x]=", p["x"]}], TrackedSymbols -> {n}]]}] ], Button["update counter", n++], {{n,0}, None} ] 

The above version is on your own notebook, in which there is nothing in the notebook.

Close M, then run it, then open Notepad and I will see the above message.

Now, at first I thought that to delete the message I need to change p ["x"] to p [x] so that I close the aforementioned laptop and make a new notebook with this code:

 Manipulate[ DynamicModule[{p}, p = 0; Row[{Dynamic[Refresh[p++; Row[{"p=", p}], TrackedSymbols -> {n}]]}] ], Button["update counter", n++], {{n, 0}, None} ] 

Then I closed M and started it again and opened the above notepad, and now I did not see a warning message. But when I repeated this process, I saw the same error.

(I sent this question to the Math group, but it’s slow, and my post didn’t even appear there, but in this post I said that the error disappeared when I changed p ["x"] to p [x] because it actually happened at first, but when I later tried, the message returned that I do not understand why)

p ["x"] is an indexed object, as described on this page:

http://reference.wolfram.com/mathematica/tutorial/MakingDefinitionsForIndexedObjects.html

Question: what in the above code causes this warning to appear? Am I writing something wrong in the above example?

The code works fine after turning on the speakers. By the way, I open this laptop from the same folder in which I open all my other laptops, nothing has changed, and this is on the home PC, there is no shared folder and nothing unusual.

Here is a link to laptop security

http://reference.wolfram.com/mathematica/tutorial/NotebookSecurity.html

I do not see anything in this that is related to what I am doing. All I can say is the use of DynamicModule [] inside Manipulate, which itself is a dynamic module. But I do not understand this well enough to understand why this is a problem.

Update 1

I do not see how this relates to the path. I can remove the error simply by commenting on the internal dynamic, like this:

 Manipulate[ (* DynamicModule[{p}, p["x"]=0; Row[{Dynamic[Refresh[p["x"]++;Row[{"p[x]=",p["x"]}],TrackedSymbols-> \ {n}]]}] ], *) n, Button["update counter", n++], {{n, 0}, None} ] 

Save the laptop, close M, start M, open notepad. The error has disappeared.

So this is in code.

Update 2

Trying to reproduce what Yoda said in his answer, I cannot.

  • make a new laptop, enter Dynamic@DateString []
  • ENTER to rate.
  • SAVE
  • close M
  • open M
  • open laptop
  • no mistakes

enter image description here

Update dec 21, 2001

At the Math Group, John Fulz was kind enough to reply to my post; I don't think he will mind if I post his answer here so you can see others.

 > > So, why is using p["x"] causing the security warning message? That is a bug, which has already been fixed in development sources. John Fultz User Interface Group Wolfram Research, Inc. 

Sorry, I do not have a link to include in his answer, I could not find a link to google now. I use thunderbird to read newsgroups.

Should this question remain open? Or should it be closed? If I need to close it, I can accept one of the answers so that it is closed.

+4
source share
4 answers

This is more a continuation of Yoda's answer and comments than a separate standalone answer, but, as was said, if you open a laptop from an unreliable directory and you have dynamic content in the output cell, you will receive a security warning. If you rate the following code:

 CurrentValue[$FrontEnd, {"NotebookSecurityOptions", "TrustedPath"}] CurrentValue[$FrontEnd, {"NotebookSecurityOptions", "UntrustedPath"}] NotebookDirectory[] 

you can make sure that your laptop is in a safe or unreliable path (despite the appearance or absence of a security warning).

+3
source

Assuming you are using the default settings (ie, "TrustByDefault" → Automatic), you will see one of three behaviors.

  • If the laptop is located in the directory specified in "TrustedPath", the content is considered safe and you will never see a warning.

  • If the laptop is located in the directory specified in "UntrustedPath", the content is considered unsafe and you will always see a warning.

  • If the laptop is in a directory that is not listed in either TrustedPath or UntrustedPath, you may or may not see a warning depending on the contents of the DynamicBox expression stored in the laptop. Mathematica will consider the expression before trying to evaluate it. If it contains only expressions from a short whitelist of “safe” expressions, you will not see a warning. If it contains any expressions that are not included in the whitelist of “safe” expressions, then you will see a warning.

+3
source

This is not due to a specific code example, but because of the Mathematica security features. From tutorial/NotebookSecurity ,

When a user opens a laptop with dynamic content, Mathematica will first determine if the laptop directory is trusted, not trusted, or not.

  • If the laptop catalog is trusted, the laptop will be allowed to automatically perform dynamic evaluations without warning the user.
  • If the laptop catalog is not trusted, the user will be warned whenever the laptop attempts to perform dynamic evaluations.
    enter image description here

By default, only $InstallationDirectory , $BaseDirectory and $UserBaseDirectory are "trusted". In addition, there is a set of directories that always do not trust (can be changed). These are your downloads.
The solution now is to add the current working directory to the list of trusted folders.

Go to Preferences > Advanced > Open Options Inspector and under Global Preferences , start a trusted search and you will see how three options appear. You can add them here.

enter image description here

+2
source

I also had a problem with this message appearing on laptops that I thought did not occur before, but now I am convinced that this is due to the dynamic output existing in the laptop and the fact that the dynamic output works in front end. Therefore, when you open a laptop with a dynamic output, it will try to start it. If you delete all the dynamic output from the laptop, save it, close it (and even close and open Mathematica again), then open the notebook again, the message should not appear, since there is no dynamic output.

I did as yoda suggested, I opened the option inspector and edited TrustedPath in the global settings. I am posting this “response” as a continuation of yoda's answer, since I had to play some game to figure out how to add the path to TrustedPath.

I added the documents as a trusted path as follows (on Mac OS 10.6) (and I try not to save anything where I don't trust):

  • Click on the small edit button to the left of the Value column for TrustedPath.
  • Click "Add" in the window that opens.
  • You will be presented

    FrontEnd`FileName [{$ RootDirectory}, "x"]

  • Replace x with the path you want to trust, for example:

    FrontEnd`FileName [{$ RootDirectory}, "/ Users / John / Documents /"]

Now I never get an annoying warning for laptops stored in documents or in any of its subfolders.

+2
source

Source: https://habr.com/ru/post/1387289/


All Articles