1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-06-25 05:29:31 +00:00

Tweak security menu items

Changed "Use Keep-Alive Hack" to "Disable Keep-Alive Hack" to emphasize
that it defaults to enabled.  Added a menu item for "Disable Security
Sandbox".  Added a warning to both that tells the user that they must
reopen the current project for the change to take effect.

Note neither of these is persisted in app settings.
This commit is contained in:
Andy McFadden 2020-07-18 13:47:01 -07:00
parent c97d85974f
commit 4928dfd872
4 changed files with 44 additions and 19 deletions

View File

@ -189,9 +189,9 @@ namespace SourceGen {
/// <summary>
/// If true, plugins will execute in the main application's AppDomain instead of
/// the sandbox.
/// the sandbox (effectively disabling the security features).
/// </summary>
private bool mUseMainAppDomainForPlugins = false;
public bool UseMainAppDomainForPlugins { get; private set; }
/// <summary>
/// Code list column numbers.
@ -720,7 +720,7 @@ namespace SourceGen {
MessageBoxImage.Error);
return false;
}
proj.UseMainAppDomainForPlugins = mUseMainAppDomainForPlugins;
proj.UseMainAppDomainForPlugins = UseMainAppDomainForPlugins;
proj.Initialize(fileData.Length);
proj.PrepForNew(fileData, Path.GetFileName(dataPathName));
@ -1093,7 +1093,7 @@ namespace SourceGen {
}
DisasmProject newProject = new DisasmProject();
newProject.UseMainAppDomainForPlugins = mUseMainAppDomainForPlugins;
newProject.UseMainAppDomainForPlugins = UseMainAppDomainForPlugins;
// Deserialize the project file. I want to do this before loading the data file
// in case we decide to store the data file name in the project (e.g. the data
@ -4351,6 +4351,16 @@ namespace SourceGen {
public void Debug_ToggleKeepAliveHack() {
ScriptManager.UseKeepAliveHack = !ScriptManager.UseKeepAliveHack;
if (mProject != null) {
MessageBox.Show("Project must be closed and re-opened for change to take effect");
}
}
public void Debug_ToggleSecuritySandbox() {
UseMainAppDomainForPlugins = !UseMainAppDomainForPlugins;
if (mProject != null) {
MessageBox.Show("Project must be closed and re-opened for change to take effect");
}
}
public void Debug_ApplesoftToHtml() {

View File

@ -160,14 +160,12 @@ and executed in a sandbox with security restrictions.</p>
<p>SourceGen defines an interface that plugins must implement, and an
interface that plugins can use to interact with SourceGen. See
Interfaces.cs in the PluginCommon directory. <b>Bear in mind that this
feature is still evolving, and the interfaces may change significantly
in the near future.</b></p>
Interfaces.cs in the PluginCommon directory.</p>
<p>The current interfaces can be used to generate visualizations, to
identify inline data that follows JSR, JSL, or BRK instructions, and to
format operands. The latter can be useful for replacing immediate
load operands with symbolic constants.</p>
format operands. The latter can be used to format code and data, e.g.
replacing immediate load operands with symbolic constants.</p>
<p>Scripts may be loaded from the RuntimeData directory, or from the directory
where the project file lives. Attempts to load them from other locations
@ -179,7 +177,7 @@ invoked is not defined.</p>
<p>Scripts are currently limited to C# version 5, because the compiler
built into .NET only handles that. C# 6 and later require installing an
additional package (Roslyn).</p>
additional package ("Roslyn"), so SourceGen does not support this.</p>
<p>When a project is opened, any errors encountered by the script compiler
are reported to the user. If the project is already open, and a script
@ -206,7 +204,7 @@ and you'll get error messages.</p>
<p>Some commonly useful functions are defined in the
<code>PluginCommon.Util</code> class, which is available to plugins. These
call into the CommonUtil library, which is shared with SourceGen.
While plugins can use CommonUtil directly, they should avoid doing so. The
While plugins could use CommonUtil directly, they should avoid doing so. The
APIs there are not guaranteed to be stable, so plugins that rely on them
may break in a subsequent release of SourceGen.</p>
@ -217,7 +215,7 @@ directory, which lives next to the application executable and RuntimeData.
If the extension script is the same age or older than the DLL, SourceGen
will continue to use the existing DLL.</p>
<p>The DLLs names are a combination of the script filename and script location.
<p>The DLL names are a combination of the script filename and script location.
The compiled name for "MyPlatform/MyScript.cs" in the RuntimeData directory
will be "RT_MyPlatform_MyScript.dll". For a project-specific script, it
would look like "PROJ_MyProject_MyScript.dll".</p>
@ -423,15 +421,21 @@ not help you debug 6502 projects.</p>
the width limitation is being obeyed. These are added exactly
as shown, without comment delimiters, into generated assembly output,
which doesn't work out well if you run the assembler.</li>
<li>Use Keep-Alive Hack. If set, a "ping" is sent to the extension
<li>Disable Security Sandbox. Extension scripts are loaded and run in
a "sandbox" to prevent security issues. Setting this flag allows
them to execute with full permissions.
This setting is not persistent.</li>
<li>Disable Keep-Alive Hack. The hack sends a "ping" to the extension
script sandbox every 60 seconds. This seems to be required to avoid
an infrequently-encountered Windows bug. (See code for notes and
stackoverflow.com links.)</li>
stackoverflow.com links.)
This setting is not persistent.</li>
<li>Applesoft to HTML. An experimental feature that formats an
Applesoft program as HTML.</li>
<li>Apply Edit Commands. An experimental feature for importing values,
such as end-of-line comments, that have been generated by other
programs.</li>
<li>Export Edit Commands. Outputs comments and notes in
SourceGen Edit Command format. This is an experimental feature.</li>
<li>Apply Edit Commands. Reads a file in SourceGen Edit Command
format and applies the commands.</li>
<li>Apply Platform Symbols. An experimental feature for turning platform
symbols into address labels. This will run through the list of all
symbols loaded from .sym65 files and find addresses that fall within

View File

@ -208,7 +208,8 @@ limitations under the License.
<RoutedUICommand x:Key="Debug_ShowUndoRedoHistoryCmd" Text="Show Undo/Redo History"/>
<RoutedUICommand x:Key="Debug_SourceGenerationTestsCmd" Text="Source Generation Tests..."/>
<RoutedUICommand x:Key="Debug_ToggleCommentRulersCmd" Text="Show Comment Rulers"/>
<RoutedUICommand x:Key="Debug_ToggleKeepAliveHackCmd" Text="Use Keep-Alive Hack"/>
<RoutedUICommand x:Key="Debug_ToggleKeepAliveHackCmd" Text="Disable Keep-Alive Hack"/>
<RoutedUICommand x:Key="Debug_ToggleSecuritySandboxCmd" Text="Disable Security Sandbox"/>
<CollectionViewSource x:Key="SymbolTableSource" Source="{Binding SymbolsList}"
Filter="SymbolsList_Filter"/>
@ -354,6 +355,8 @@ limitations under the License.
Executed="Debug_ToggleCommentRulersCmd_Executed"/>
<CommandBinding Command="{StaticResource Debug_ToggleKeepAliveHackCmd}"
Executed="Debug_ToggleKeepAliveHackCmd_Executed"/>
<CommandBinding Command="{StaticResource Debug_ToggleSecuritySandboxCmd}"
Executed="Debug_ToggleSecuritySandboxCmd_Executed"/>
</Window.CommandBindings>
<DockPanel>
@ -457,6 +460,9 @@ limitations under the License.
<Separator/>
<MenuItem Name="debugCommentRulersMenuItem"
Command="{StaticResource Debug_ToggleCommentRulersCmd}" IsCheckable="True"/>
<Separator/>
<MenuItem Name="debugSecuritySandboxMenuItem"
Command="{StaticResource Debug_ToggleSecuritySandboxCmd}" IsCheckable="True"/>
<MenuItem Name="debugKeepAliveHackMenuItem"
Command="{StaticResource Debug_ToggleKeepAliveHackCmd}" IsCheckable="True"/>
<Separator/>

View File

@ -1437,6 +1437,10 @@ namespace SourceGen.WpfGui {
mMainCtrl.Debug_ToggleKeepAliveHack();
}
private void Debug_ToggleSecuritySandboxCmd_Executed(object sender, ExecutedRoutedEventArgs e) {
mMainCtrl.Debug_ToggleSecuritySandbox();
}
#endregion Command handlers
#region Misc
@ -1559,7 +1563,8 @@ namespace SourceGen.WpfGui {
}
private void DebugMenu_SubmenuOpened(object sender, RoutedEventArgs e) {
debugCommentRulersMenuItem.IsChecked = MultiLineComment.DebugShowRuler;
debugKeepAliveHackMenuItem.IsChecked = Sandbox.ScriptManager.UseKeepAliveHack;
debugKeepAliveHackMenuItem.IsChecked = !Sandbox.ScriptManager.UseKeepAliveHack;
debugSecuritySandboxMenuItem.IsChecked = mMainCtrl.UseMainAppDomainForPlugins;
debugAnalysisTimersMenuItem.IsChecked = mMainCtrl.IsDebugAnalysisTimersOpen;
debugAnalyzerOutputMenuItem.IsChecked = mMainCtrl.IsDebugAnalyzerOutputOpen;
debugUndoRedoHistoryMenuItem.IsChecked = mMainCtrl.IsDebugUndoRedoHistoryOpen;