-
Notifications
You must be signed in to change notification settings - Fork 8.7k
Warn before the user runs a new commandline elevated #11308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
zadjii-msft
wants to merge
124
commits into
main
from
dev/migrie/f/non-terminal-content-elevation-warning
Closed
Changes from all commits
Commits
Show all changes
124 commits
Select commit
Hold shift + click to select a range
42c3eea
pull application state members into a base class
zadjii-msft eb243f5
Split ApplicationState into a Base and add an Elevated version
zadjii-msft 2857324
proof of concept add a dialog to pop when opening new tabs
zadjii-msft ccbcb42
Merge remote-tracking branch 'origin/main' into dev/migrie/f/elevatio…
zadjii-msft 14d21f4
nits, cleanup
zadjii-msft c66a566
Allow a Pane to host a UserControl instead of a TermControl
zadjii-msft ed1cf2a
add the boilerplate for a custom content dialog like thing
zadjii-msft 1ee3522
Allow a TerminalTab to have a UserControl
zadjii-msft 7fb7d64
These are things I might need for #997
zadjii-msft 631cdf7
Who ever said nested lambdas is a bad thing?
zadjii-msft 736a351
This works amazingly well
zadjii-msft 7f29e1e
More things we might need for Non-Terminal content, #997
zadjii-msft 9b32681
This works to prompt before splitting a pane
zadjii-msft 58c6646
Format that dialog with the actual commandline
zadjii-msft e5dc64e
Hot-reload the elevated state?
zadjii-msft 64898b1
update other panes too
zadjii-msft b592155
Merge remote-tracking branch 'origin/main' into dev/migrie/f/non-term…
zadjii-msft 447c2f9
I think this creates a test file that's only accessible by SYSTEM. As…
zadjii-msft 880222d
This file isn't even readable by admins, so maybe that's bad
zadjii-msft 5197dc4
this worked, nice
zadjii-msft 721b636
unfortunately, we can't _write_ this file...
zadjii-msft 8569211
Now, we can update the file after it's created
zadjii-msft aef422d
This is definitely not right.
zadjii-msft 9a1cf5a
bunch of dead ends
zadjii-msft 7854abe
I bet that's what I was doing wrong. The rename is just dandy, it don…
zadjii-msft 6265f4f
this looks like it checks the permissions as we'd expect
zadjii-msft 1111d41
This works to do the 'blow the file away when permissions have change…
zadjii-msft 4f697ec
I thing this was unneeded
zadjii-msft 4da965f
Merge remote-tracking branch 'origin/main' into dev/migrie/f/non-term…
zadjii-msft 1e3a319
more unique_sid's, and m,ore comments
zadjii-msft d6c2fb5
THis fixes #7754
zadjii-msft 6be6972
This is everything from dev/migrie/f/non-terminal-content-elevation-w…
zadjii-msft c106f64
:facepalm:
zadjii-msft 51e0473
minor nits
zadjii-msft da0cc7b
todo! in the code
zadjii-msft 4e69a32
bunch of new allowed words
zadjii-msft 6757452
fix the tests
zadjii-msft edd7126
Merge branch 'dev/migrie/f/just-elevated-state-2' into dev/migrie/f/n…
zadjii-msft 47d55a8
don't do the lookup for things in system32
zadjii-msft 54a0027
comments
zadjii-msft 723037e
fix the focus thing, frick the env vars thing
zadjii-msft d944a68
manually allow env var parsing. Remember that wsl needs manual allows…
zadjii-msft 56d5f9e
every day I'm mangling
zadjii-msft a4acdeb
blindly remove ElevatedState
zadjii-msft 5685063
Merge remote-tracking branch 'origin/main' into dev/migrie/f/just-ele…
zadjii-msft d0f05f6
Merge branch 'dev/migrie/f/just-elevated-state-2' into dev/migrie/f/n…
zadjii-msft 7f9f75c
gah, I might have broke persisting window state
zadjii-msft 9b3b9e0
remove baseapplicationstate and just merge it back in
zadjii-msft 5a8e27e
Merge branch 'dev/migrie/f/just-elevated-state-2' into dev/migrie/f/n…
zadjii-msft 507a48e
Merge remote-tracking branch 'origin/main' into dev/migrie/f/just-ele…
zadjii-msft b1b1bef
this is a crazy idea that I hate but gotta start somewhere
zadjii-msft b755eb0
Merge remote-tracking branch 'origin/main' into dev/migrie/f/non-term…
zadjii-msft b279601
Merge branch 'dev/migrie/f/just-elevated-state-2' into dev/migrie/f/n…
zadjii-msft 94c4cca
I think this works ALMOST as I want
zadjii-msft 64d02f2
Move window state, approvedCommandlines into `user-state.json`
zadjii-msft de9dc32
pr nits
zadjii-msft 8635537
fix hot reloading for this file
zadjii-msft 7e2e4ea
I think this works ALMOST as I want
zadjii-msft f3738f5
Move window state, approvedCommandlines into `user-state.json`
zadjii-msft a6e044d
pr nits
zadjii-msft eee657b
fix hot reloading for this file
zadjii-msft 02e9871
Merge remote-tracking branch 'origin/main' into dev/migrie/f/just-ele…
zadjii-msft 7e2b371
Merge branch 'dev/migrie/f/just-elevated-state-2' into dev/migrie/f/n…
zadjii-msft 5ff9a24
okay so I guess that's not a word
zadjii-msft 62fe823
Merge branch 'dev/migrie/f/just-elevated-state-2' into dev/migrie/f/n…
zadjii-msft 5e9d0b8
use the background from the control when we can
zadjii-msft a3ac32a
derp
zadjii-msft abb847b
pr nits from miniksa
zadjii-msft 620ee30
Merge remote-tracking branch 'origin/main' into dev/migrie/f/just-ele…
zadjii-msft a751156
Merge branch 'dev/migrie/f/just-elevated-state-2' into dev/migrie/f/n…
zadjii-msft d053f6c
Merge remote-tracking branch 'origin/main' into dev/migrie/f/just-ele…
zadjii-msft 5699229
Apply suggestions from code review
zadjii-msft 866832b
This seemingly works the way I'd expect, going to merge into the warn…
zadjii-msft ff33387
Merge branch 'dev/migrie/f/just-elevated-state-2' into dev/migrie/f/n…
zadjii-msft b4e0496
cleanup
zadjii-msft 9ff2775
Merge branch 'dev/migrie/f/just-trying-something-on-just-elevated-sta…
zadjii-msft 48b20de
Add some logging. Can't seem to get the crash to repro?
zadjii-msft 3c1866a
Merge remote-tracking branch 'origin/dev/migrie/b/1.12-crash-on-exit'…
zadjii-msft aea3752
we want this
zadjii-msft 0e7217d
Merge commit 'aea37520b3cdb1c1752a6c8e0ff598991518ce28' into dev/migr…
zadjii-msft ae99ce9
teh
zadjii-msft f49c3fc
Merge branch 'dev/migrie/f/just-elevated-state-2' into dev/migrie/f/n…
zadjii-msft bf3c6e7
spel is hard
zadjii-msft faa06f8
Merge remote-tracking branch 'origin/main' into dev/migrie/f/just-ele…
zadjii-msft 945c81d
Merge remote-tracking branch 'origin/main' into dev/migrie/f/just-ele…
zadjii-msft 21d6ffe
Merge branch 'dev/migrie/f/just-elevated-state-2' into dev/migrie/f/n…
zadjii-msft fe5a78c
Fix OpenConsoleProxy for Debug builds
lhecker 90b7962
Merge remote-tracking branch 'origin/dev/lhecker/proxy-no-default-lib…
zadjii-msft 69f1068
update appearance
zadjii-msft 242de14
Incredible that this works at all
zadjii-msft d6d7087
Cleanup from the experimentation phase
zadjii-msft 7fb4906
More cleanup
zadjii-msft b9979ff
Esc to dismiss too
zadjii-msft bdf0816
spel
zadjii-msft 3a8a83a
last pr nits
zadjii-msft 9b4ae9e
Merge remote-tracking branch 'origin/main' into dev/migrie/f/just-ele…
zadjii-msft 25c34df
Merge branch 'dev/migrie/f/just-elevated-state-2' into dev/migrie/f/n…
zadjii-msft c90eb87
good catch
zadjii-msft 4976a09
this is a collection of the trivial nits while I wait on a reply to t…
zadjii-msft fd849a5
trying to do the thing eryksun mentioned. This seems to actually work…
zadjii-msft 25b2675
this works really quite well
zadjii-msft b212871
this is the right way to initialize the unique_hlocal_security_descri…
zadjii-msft 4f16dfb
many comments
zadjii-msft a93d17e
I believe this is the rest of the comments
zadjii-msft ce6a9c5
Merge remote-tracking branch 'origin/main' into dev/migrie/f/just-ele…
zadjii-msft c09bdbd
Merge branch 'dev/migrie/f/just-elevated-state-2' into dev/migrie/f/n…
zadjii-msft fdc5749
make text selectable
zadjii-msft 5253c11
make sure event handlers get replaced, too
zadjii-msft 1c66877
pwsh core fixed too
zadjii-msft 7024f44
whoops
zadjii-msft db9cbf3
spell
zadjii-msft 08cbd16
the last of it?
zadjii-msft 999f21f
Merge remote-tracking branch 'origin/main' into dev/migrie/f/just-ele…
zadjii-msft 33e96e7
mitigate a TOCTOU
zadjii-msft 7f03d4d
dustins nits
zadjii-msft 97d11d1
Merge branch 'dev/migrie/f/just-elevated-state-2' into dev/migrie/f/n…
zadjii-msft bad27a9
THIS NEEDS TO GO TO THE PARENT
zadjii-msft fd72b79
Merge remote-tracking branch 'origin/main' into dev/migrie/f/non-term…
zadjii-msft 8e43c9d
more tests
zadjii-msft 2445ced
this passes all the tests
zadjii-msft 25947c2
cleanup for the tests"
zadjii-msft 056446c
guard some GetActiveTerminalControl calls
zadjii-msft 841ced7
cant type when it's 26 degrees in here
zadjii-msft 065e5f7
fix unit test build
zadjii-msft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
src/cascadia/LocalTests_TerminalApp/TrustCommandlineTests.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
// | ||
// A series of tests for the TerminalPage::_isTrustedCommandline function. | ||
// That's a heuristic function for deciding if we should automatically trust | ||
// certain commandlines by default. The logic in there is weird and there are | ||
// lots of edge cases, so it's easier to just write a unit test. | ||
|
||
#include "pch.h" | ||
|
||
#include "../TerminalApp/TerminalPage.h" | ||
|
||
using namespace Microsoft::Console; | ||
using namespace TerminalApp; | ||
using namespace winrt::TerminalApp; | ||
using namespace winrt::Microsoft::Terminal::Settings::Model; | ||
|
||
using namespace WEX::Logging; | ||
using namespace WEX::TestExecution; | ||
using namespace WEX::Common; | ||
|
||
using namespace winrt::Windows::ApplicationModel::DataTransfer; | ||
using namespace winrt::Windows::Foundation::Collections; | ||
using namespace winrt::Windows::System; | ||
using namespace winrt::Windows::UI::Xaml; | ||
using namespace winrt::Windows::UI::Xaml::Controls; | ||
using namespace winrt::Windows::UI::Core; | ||
using namespace winrt::Windows::UI::Text; | ||
|
||
namespace winrt | ||
{ | ||
namespace MUX = Microsoft::UI::Xaml; | ||
namespace WUX = Windows::UI::Xaml; | ||
using IInspectable = Windows::Foundation::IInspectable; | ||
} | ||
|
||
namespace TerminalAppLocalTests | ||
{ | ||
class TrustCommandlineTests | ||
{ | ||
BEGIN_TEST_CLASS(TrustCommandlineTests) | ||
END_TEST_CLASS() | ||
|
||
TEST_METHOD(SimpleTests); | ||
TEST_METHOD(TestCommandlineWithArgs); | ||
TEST_METHOD(TestCommandlineWithSpaces); | ||
TEST_METHOD(TestCommandlineWithEnvVars); | ||
TEST_METHOD(WslTests); | ||
TEST_METHOD(TestPwshLocation); | ||
|
||
bool trust(std::wstring_view cmdline); | ||
}; | ||
|
||
bool TrustCommandlineTests::trust(std::wstring_view cmdline) | ||
{ | ||
return implementation::TerminalPage::_isTrustedCommandline(cmdline); | ||
} | ||
|
||
void TrustCommandlineTests::SimpleTests() | ||
{ | ||
VERIFY_IS_TRUE(trust(L"C:\\Windows\\System32\\cmd.exe")); | ||
VERIFY_IS_TRUE(trust(L"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe")); | ||
VERIFY_IS_FALSE(trust(L"C:\\Windows\\System32\\i-definitely-don't-exist.exe")); | ||
|
||
Log::Comment(L"These are not fully qualified, and _shouldn't_ be trusted"); | ||
VERIFY_IS_FALSE(trust(L"cmd.exe")); | ||
VERIFY_IS_FALSE(trust(L"powershell.exe")); | ||
} | ||
|
||
void TrustCommandlineTests::TestCommandlineWithArgs() | ||
{ | ||
Log::Comment(L"These are sneaky things that _shouldn't_ be trusted"); | ||
VERIFY_IS_FALSE(trust(L"C:\\Windows\\System32\\cmd.exe /k echo Boo!")); | ||
VERIFY_IS_FALSE(trust(L"C:\\Windows\\System32\\cmd.exe /k echo Boo! & cmd.exe")); | ||
} | ||
|
||
void TrustCommandlineTests::TestCommandlineWithSpaces() | ||
{ | ||
Log::Comment(L"This is a valid place for powershell to live, and the space can be tricky"); | ||
VERIFY_IS_TRUE(trust(L"C:\\Program Files\\PowerShell\\7\\pwsh.exe")); | ||
|
||
Log::Comment(L"These are sneaky things that _shouldn't_ be trusted"); | ||
VERIFY_IS_FALSE(trust(L"C:\\Windows\\System 32\\cmd.exe")); | ||
VERIFY_IS_FALSE(trust(L"C:\\Windows\\System32\\ cmd.exe")); | ||
VERIFY_IS_FALSE(trust(L"C:\\Windows\\System32\\cmd.exe /c cmd.exe")); | ||
} | ||
|
||
void TrustCommandlineTests::TestCommandlineWithEnvVars() | ||
{ | ||
Log::Comment(L"Make sure we auto-expand environment variables"); | ||
|
||
VERIFY_IS_TRUE(trust(L"%WINDIR%\\system32\\cmd.exe")); | ||
VERIFY_IS_TRUE(trust(L"%WINDIR%\\system32\\WindowsPowerShell\\v1.0\\powershell.exe")); | ||
VERIFY_IS_TRUE(trust(L"%ProgramFiles%\\PowerShell\\7\\pwsh.exe")); | ||
} | ||
|
||
void TrustCommandlineTests::WslTests() | ||
{ | ||
Log::Comment(L"We are explicitly deciding to not auto-approve " | ||
L"`wsl.exe -d distro`-like commandlines. If we change this" | ||
L" policy, remove this test."); | ||
|
||
VERIFY_IS_FALSE(trust(L"C:\\Windows\\System32\\wsl")); | ||
VERIFY_IS_TRUE(trust(L"C:\\Windows\\System32\\wsl.exe"), L"This we will trust though, since it's an exe in system32"); | ||
VERIFY_IS_FALSE(trust(L"C:\\Windows\\System32\\wsl.exe -d Ubuntu")); | ||
VERIFY_IS_FALSE(trust(L"wsl.exe")); | ||
} | ||
|
||
void TrustCommandlineTests::TestPwshLocation() | ||
{ | ||
Log::Comment(L"Test various locations that pwsh.exe can be in"); | ||
|
||
VERIFY_IS_TRUE(trust(L"%ProgramFiles%\\PowerShell\\7\\pwsh.exe")); | ||
VERIFY_IS_TRUE(trust(L"%LOCALAPPDATA%\\Microsoft\\WindowsApps\\pwsh.exe")); | ||
VERIFY_IS_TRUE(trust(L"%ProgramFiles%\\PowerShell\\10\\pwsh.exe")); | ||
VERIFY_IS_TRUE(trust(L"%ProgramFiles%\\PowerShell\\7.1.5\\pwsh.exe")); | ||
|
||
Log::Comment(L"These are sneaky things that _shouldn't_ be trusted"); | ||
VERIFY_IS_FALSE(trust(L"%ProgramFiles%\\PowerShell\\7\\pwsh.exe bad-stuff pwsh.exe")); | ||
VERIFY_IS_FALSE(trust(L"%ProgramFiles%\\PowerShell\\7\\pwsh.exe bad-stuff c:\\pwsh.exe")); | ||
VERIFY_IS_FALSE(trust(L"%ProgramFiles%\\PowerShell\\7\\pwsh.exe bad-stuff c:\\ %ProgramFiles%\\PowerShell\\7\\pwsh.exe")); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
#pragma once | ||
|
||
#include "pch.h" | ||
#include "AdminWarningPlaceholder.h" | ||
#include "AdminWarningPlaceholder.g.cpp" | ||
#include <LibraryResources.h> | ||
using namespace winrt::Windows::UI::Xaml; | ||
|
||
namespace winrt::TerminalApp::implementation | ||
{ | ||
AdminWarningPlaceholder::AdminWarningPlaceholder(const winrt::Microsoft::Terminal::Control::TermControl& control, const winrt::hstring& cmdline) : | ||
_control{ control }, | ||
_Commandline{ cmdline } | ||
{ | ||
InitializeComponent(); | ||
// If the content we're hosting is a TermControl, then use the control's | ||
// BG as our BG, to give the impression that it's there, under the | ||
// dialog. | ||
if (const auto termControl{ control.try_as<winrt::Microsoft::Terminal::Control::TermControl>() }) | ||
{ | ||
RootGrid().Background(termControl.BackgroundBrush()); | ||
} | ||
} | ||
void AdminWarningPlaceholder::_primaryButtonClick(winrt::Windows::Foundation::IInspectable const& /*sender*/, | ||
RoutedEventArgs const& e) | ||
{ | ||
_PrimaryButtonClickedHandlers(*this, e); | ||
} | ||
void AdminWarningPlaceholder::_cancelButtonClick(winrt::Windows::Foundation::IInspectable const& /*sender*/, | ||
RoutedEventArgs const& e) | ||
{ | ||
_CancelButtonClickedHandlers(*this, e); | ||
} | ||
winrt::Windows::UI::Xaml::Controls::UserControl AdminWarningPlaceholder::Control() | ||
{ | ||
return _control; | ||
} | ||
|
||
// Method Description: | ||
// - Move the focus to the cancel button by default. This has the LOAD | ||
// BEARING side effect of also triggering Narrator to read out the | ||
// contents of the dialog. It's unclear why doing this works, but it does. | ||
// - Using a LayoutUpdated event to trigger the focus change when we're | ||
// added to the UI tree did not seem to work. | ||
// - Whoever is adding us to the UI tree is responsible for calling this! | ||
// Arguments: | ||
// - <none> | ||
// Return Value: | ||
// - <none> | ||
Comment on lines
+42
to
+52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any possible way we could write a test to verify that this is happening? Like ensure that the event that's being triggered continues to happen with a UIA test that launches the warning? (Follow on issue?) |
||
void AdminWarningPlaceholder::FocusOnLaunch() | ||
{ | ||
CancelButton().Focus(FocusState::Programmatic); | ||
} | ||
|
||
winrt::hstring AdminWarningPlaceholder::ControlName() | ||
{ | ||
return RS_(L"AdminWarningPlaceholderName"); | ||
} | ||
|
||
void AdminWarningPlaceholder::_keyUpHandler(IInspectable const& /*sender*/, | ||
Windows::UI::Xaml::Input::KeyRoutedEventArgs const& e) | ||
{ | ||
// If the user presses escape, close the dialog (without confirming) | ||
const auto key = e.OriginalKey(); | ||
if (key == winrt::Windows::System::VirtualKey::Escape) | ||
{ | ||
_CancelButtonClickedHandlers(*this, e); | ||
e.Handled(true); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/*++ | ||
Copyright (c) Microsoft Corporation | ||
Licensed under the MIT license. | ||
|
||
Module Name: | ||
- AdminWarningPlaceholder | ||
|
||
Abstract: | ||
- The AdminWarningPlaceholder is a control used to fill space in a pane and | ||
present a warning to the user. It holds on to a real control that it should be | ||
replaced with. It looks just like a ContentDialog, except it exists per-pane, | ||
whereas a ContentDialog can only be added to take up the whole window. | ||
- The caller should make sure to bind our PrimaryButtonClicked and | ||
CancelButtonClicked events, to be informed as to which was pressed. | ||
|
||
Author(s): | ||
- Mike Griese - September 2021 | ||
|
||
--*/ | ||
|
||
#pragma once | ||
|
||
#include "AdminWarningPlaceholder.g.h" | ||
#include "../../cascadia/inc/cppwinrt_utils.h" | ||
|
||
namespace winrt::TerminalApp::implementation | ||
{ | ||
struct AdminWarningPlaceholder : AdminWarningPlaceholderT<AdminWarningPlaceholder> | ||
{ | ||
AdminWarningPlaceholder(const winrt::Microsoft::Terminal::Control::TermControl& control, const winrt::hstring& cmdline); | ||
void FocusOnLaunch(); | ||
winrt::Windows::UI::Xaml::Controls::UserControl Control(); | ||
winrt::hstring ControlName(); | ||
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler); | ||
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, Commandline, _PropertyChangedHandlers); | ||
TYPED_EVENT(PrimaryButtonClicked, TerminalApp::AdminWarningPlaceholder, winrt::Windows::UI::Xaml::RoutedEventArgs); | ||
TYPED_EVENT(CancelButtonClicked, TerminalApp::AdminWarningPlaceholder, winrt::Windows::UI::Xaml::RoutedEventArgs); | ||
|
||
private: | ||
friend struct AdminWarningPlaceholderT<AdminWarningPlaceholder>; // friend our parent so it can bind private event handlers | ||
|
||
winrt::Microsoft::Terminal::Control::TermControl _control{ nullptr }; | ||
|
||
void _primaryButtonClick(winrt::Windows::Foundation::IInspectable const& sender, | ||
winrt::Windows::UI::Xaml::RoutedEventArgs const& e); | ||
void _cancelButtonClick(winrt::Windows::Foundation::IInspectable const& sender, | ||
winrt::Windows::UI::Xaml::RoutedEventArgs const& e); | ||
void _keyUpHandler(Windows::Foundation::IInspectable const& sender, | ||
Windows::UI::Xaml::Input::KeyRoutedEventArgs const& e); | ||
}; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
namespace TerminalApp | ||
{ | ||
[default_interface] runtimeclass AdminWarningPlaceholder : Windows.UI.Xaml.Controls.UserControl, | ||
Windows.UI.Xaml.Data.INotifyPropertyChanged | ||
{ | ||
String Commandline { get; }; | ||
String ControlName { get; }; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<!-- | ||
Copyright (c) Microsoft Corporation. All rights reserved. Licensed under | ||
the MIT License. See LICENSE in the project root for license information. | ||
--> | ||
<UserControl x:Class="TerminalApp.AdminWarningPlaceholder" | ||
zadjii-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="using:TerminalApp" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:mux="using:Microsoft.UI.Xaml.Controls" | ||
AutomationProperties.AccessibilityView="Content" | ||
AutomationProperties.IsDialog="True" | ||
AutomationProperties.Name="{x:Bind ControlName, Mode=OneWay}" | ||
PreviewKeyUp="_keyUpHandler" | ||
mc:Ignorable="d"> | ||
|
||
<!-- | ||
We have to use two grids to be tricky here: | ||
- The outer grid will get its background from the control it hosts, and | ||
expands to fit its container. This will make it look like the background | ||
fills the space available. | ||
- The inner grid is set to Center,Center, so that the "dialog" appears | ||
centered | ||
--> | ||
|
||
<Grid x:Name="RootGrid" | ||
HorizontalAlignment="Stretch" | ||
VerticalAlignment="Stretch"> | ||
<Grid HorizontalAlignment="Center" | ||
VerticalAlignment="Center"> | ||
<Border Margin="8,8,8,8" | ||
Padding="16,8,16,8" | ||
AllowFocusOnInteraction="True" | ||
AutomationProperties.AccessibilityView="Raw" | ||
AutomationProperties.IsDialog="True" | ||
Background="{ThemeResource SystemControlBackgroundAltHighBrush}" | ||
BorderBrush="{ThemeResource SystemAccentColor}" | ||
BorderThickness="2,2,2,2" | ||
CornerRadius="{ThemeResource OverlayCornerRadius}"> | ||
<StackPanel Orientation="Vertical"> | ||
<TextBlock x:Name="ApproveCommandlineWarningTitle" | ||
x:Uid="ApproveCommandlineWarningTitle" | ||
Padding="0,0,0,16" | ||
HorizontalAlignment="Left" | ||
FontSize="20" | ||
FontWeight="Normal" | ||
IsTextSelectionEnabled="True" | ||
TextWrapping="WrapWholeWords" /> | ||
|
||
<TextBlock x:Name="PrefixTextBlock" | ||
x:Uid="ApproveCommandlineWarningPrefixTextBlock" | ||
HorizontalAlignment="Left" | ||
IsTextSelectionEnabled="True" | ||
TextWrapping="WrapWholeWords" /> | ||
|
||
<TextBlock x:Name="CommandlineText" | ||
Margin="0,16,0,16" | ||
HorizontalAlignment="Left" | ||
FontFamily="Cascadia Mono" | ||
IsTextSelectionEnabled="True" | ||
Text="{x:Bind Commandline, Mode=OneWay}" | ||
TextWrapping="WrapWholeWords" /> | ||
|
||
<TextBlock x:Name="SuffixTextBlock" | ||
x:Uid="ApproveCommandlineWarningSuffixTextBlock" | ||
HorizontalAlignment="Left" | ||
IsTextSelectionEnabled="True" | ||
TextWrapping="WrapWholeWords" /> | ||
<Grid Margin="0,8,0,8" | ||
HorizontalAlignment="Stretch" | ||
XYFocusKeyboardNavigation="Enabled"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="*" /> | ||
<ColumnDefinition Width="*" /> | ||
</Grid.ColumnDefinitions> | ||
<Button x:Name="PrimaryButton" | ||
x:Uid="ApproveCommandlineWarning_PrimaryButton" | ||
Grid.Column="0" | ||
Margin="0,0,8,0" | ||
HorizontalAlignment="Stretch" | ||
Click="_primaryButtonClick" | ||
IsTabStop="True" | ||
Style="{StaticResource AccentButtonStyle}" /> | ||
<Button x:Name="CancelButton" | ||
x:Uid="ApproveCommandlineWarning_CancelButton" | ||
Grid.Column="1" | ||
HorizontalAlignment="Stretch" | ||
Click="_cancelButtonClick" | ||
IsTabStop="True" /> | ||
</Grid> | ||
</StackPanel> | ||
</Border> | ||
</Grid> | ||
</Grid> | ||
|
||
</UserControl> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.