added maske command with masked password (but only password!)

This commit is contained in:
michael starke
2017-10-27 10:44:37 +02:00
parent d6f4411313
commit 90cff33055
4 changed files with 43 additions and 115 deletions

View File

@@ -23,14 +23,14 @@
<rect key="frame" x="1" y="0.0" width="438" height="251"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" columnSelection="YES" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" rowSizeStyle="automatic" headerView="Ixq-CN-2h1" viewBased="YES" id="Ih2-lo-t2W">
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" columnReordering="NO" multipleSelection="NO" autosaveColumns="NO" typeSelect="NO" rowSizeStyle="automatic" headerView="Ep2-Qz-mIE" viewBased="YES" id="Ih2-lo-t2W">
<rect key="frame" x="0.0" y="0.0" width="438" height="228"/>
<autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
<tableColumns>
<tableColumn width="116" minWidth="40" maxWidth="1000" id="wTy-0L-yzY">
<tableColumn width="435" minWidth="40" maxWidth="1000" id="wTy-0L-yzY">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
@@ -41,16 +41,21 @@
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES"/>
<prototypeCellViews>
<tableCellView id="emA-5O-NDD">
<rect key="frame" x="1" y="1" width="116" height="17"/>
<tableCellView id="vkI-FK-7wg">
<rect key="frame" x="1" y="1" width="435" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="fQ0-QM-oX6">
<rect key="frame" x="0.0" y="0.0" width="116" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="UEw-gx-717">
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Utl-Gl-ETE">
<rect key="frame" x="3" y="0.0" width="17" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" heightSizable="YES"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="NSActionTemplate" id="gT4-lt-7Ir"/>
</imageView>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" allowsExpansionToolTips="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Dxk-A7-QSy">
<rect key="frame" x="25" y="0.0" width="410" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="TN3-3a-LaA">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
@@ -58,7 +63,8 @@
</textField>
</subviews>
<connections>
<outlet property="textField" destination="fQ0-QM-oX6" id="Apx-6T-sOh"/>
<outlet property="imageView" destination="Utl-Gl-ETE" id="5dQ-R4-kfV"/>
<outlet property="textField" destination="Dxk-A7-QSy" id="8uP-9M-aOd"/>
</connections>
</tableCellView>
</prototypeCellViews>
@@ -72,14 +78,14 @@
</subviews>
</clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="Xgd-fL-vdl">
<rect key="frame" x="1" y="215" width="438" height="16"/>
<rect key="frame" x="1" y="235" width="92" height="16"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="5cX-o7-7ZJ">
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="5cX-o7-7ZJ">
<rect key="frame" x="224" y="17" width="15" height="102"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<tableHeaderView key="headerView" id="Ixq-CN-2h1">
<tableHeaderView key="headerView" id="Ep2-Qz-mIE">
<rect key="frame" x="0.0" y="0.0" width="438" height="23"/>
<autoresizingMask key="autoresizingMask"/>
</tableHeaderView>
@@ -101,6 +107,9 @@
Gw
</string>
</buttonCell>
<connections>
<action selector="cancelSelection:" target="-1" id="EzT-DQ-zhY"/>
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="V5B-Qq-GN8">
<rect key="frame" x="318" y="13" width="148" height="32"/>
@@ -110,6 +119,9 @@ Gw
<string key="keyEquivalent" base64-UTF8="YES">
DQ
</string>
<connections>
<action selector="selectAutotypeContext:" target="-1" id="rAk-rF-Ncv"/>
</connections>
</buttonCell>
</button>
</subviews>
@@ -130,4 +142,7 @@ DQ
<point key="canvasLocation" x="61" y="29.5"/>
</customView>
</objects>
<resources>
<image name="NSActionTemplate" width="14" height="14"/>
</resources>
</document>

View File

@@ -1,102 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13196" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13196"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="MPAutotypeDaemon">
<connections>
<outlet property="matchSelectionButton" destination="tAw-72-pSm" id="2a0-3C-UUB"/>
<outlet property="matchSelectionWindow" destination="1" id="ZYa-oC-Nfs"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window title="Autotype Selection" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" oneShot="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="1">
<windowStyleMask key="styleMask" titled="YES"/>
<rect key="contentRect" x="196" y="240" width="229" height="459"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
<view key="contentView" id="2">
<rect key="frame" x="0.0" y="0.0" width="353" height="156"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="NdQ-vM-dHT">
<rect key="frame" x="109" y="13" width="82" height="32"/>
<buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="WJJ-kW-fak">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
<string key="keyEquivalent" base64-UTF8="YES">
Gw
</string>
</buttonCell>
<connections>
<action selector="cancelAutotypeSelection:" target="-2" id="nIA-o8-BE1"/>
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Jlm-i9-jVy">
<rect key="frame" x="191" y="13" width="148" height="32"/>
<buttonCell key="cell" type="push" title="Perform Autotype" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="AER-eU-kcu">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
<string key="keyEquivalent" base64-UTF8="YES">
DQ
</string>
</buttonCell>
<connections>
<action selector="performAutotypeWithSelectedMatch:" target="-2" id="vRo-HH-NIy"/>
</connections>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" preferredMaxLayoutWidth="330" translatesAutoresizingMaskIntoConstraints="NO" id="q1d-ED-T5M">
<rect key="frame" x="18" y="102" width="317" height="34"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" title="There are multiple matches for the current window. Please select which match should be used." id="ehp-xc-B5g">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Epz-xU-9TM">
<rect key="frame" x="18" y="64" width="87" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Match to use:" id="pLz-Kc-yPh">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<popUpButton verticalHuggingPriority="750" horizontalCompressionResistancePriority="499" translatesAutoresizingMaskIntoConstraints="NO" id="tAw-72-pSm">
<rect key="frame" x="109" y="58" width="227" height="26"/>
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" id="TAr-ZQ-aDu">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
<menu key="menu" title="OtherViews" id="7RT-wh-F0R">
<items>
<menuItem title="Item 3" id="HzV-Dh-6B9"/>
</items>
</menu>
</popUpButtonCell>
</popUpButton>
</subviews>
<constraints>
<constraint firstItem="tAw-72-pSm" firstAttribute="top" secondItem="q1d-ED-T5M" secondAttribute="bottom" constant="20" id="Bwf-bJ-2AY"/>
<constraint firstItem="Jlm-i9-jVy" firstAttribute="top" secondItem="tAw-72-pSm" secondAttribute="bottom" constant="20" symbolic="YES" id="CZ6-7H-g05"/>
<constraint firstItem="Jlm-i9-jVy" firstAttribute="leading" secondItem="NdQ-vM-dHT" secondAttribute="trailing" constant="12" symbolic="YES" id="DHs-Xz-gcZ"/>
<constraint firstAttribute="bottom" secondItem="NdQ-vM-dHT" secondAttribute="bottom" constant="20" symbolic="YES" id="Eua-I4-kKg"/>
<constraint firstAttribute="trailing" secondItem="tAw-72-pSm" secondAttribute="trailing" constant="20" symbolic="YES" id="ITA-QN-ZYj"/>
<constraint firstItem="tAw-72-pSm" firstAttribute="trailing" secondItem="q1d-ED-T5M" secondAttribute="trailing" id="MsD-dU-YC8"/>
<constraint firstItem="Epz-xU-9TM" firstAttribute="baseline" secondItem="tAw-72-pSm" secondAttribute="baseline" id="O99-nG-qmf"/>
<constraint firstAttribute="trailing" secondItem="Jlm-i9-jVy" secondAttribute="trailing" constant="20" symbolic="YES" id="QlH-af-YI1"/>
<constraint firstItem="NdQ-vM-dHT" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="2" secondAttribute="leading" constant="20" symbolic="YES" id="Rvr-iZ-RVe"/>
<constraint firstItem="Epz-xU-9TM" firstAttribute="leading" secondItem="q1d-ED-T5M" secondAttribute="leading" id="Vcg-aa-5pd"/>
<constraint firstAttribute="trailing" secondItem="q1d-ED-T5M" secondAttribute="trailing" constant="20" symbolic="YES" id="Wcu-aH-ONq"/>
<constraint firstItem="q1d-ED-T5M" firstAttribute="top" secondItem="2" secondAttribute="top" constant="20" symbolic="YES" id="eAk-Qk-bjO"/>
<constraint firstItem="q1d-ED-T5M" firstAttribute="top" relation="greaterThanOrEqual" secondItem="2" secondAttribute="top" constant="20" symbolic="YES" id="fCH-CB-BfF"/>
<constraint firstItem="Jlm-i9-jVy" firstAttribute="baseline" secondItem="NdQ-vM-dHT" secondAttribute="baseline" id="tOu-bn-J1u"/>
<constraint firstItem="q1d-ED-T5M" firstAttribute="leading" secondItem="2" secondAttribute="leading" constant="20" symbolic="YES" id="uCQ-aQ-3je"/>
<constraint firstItem="tAw-72-pSm" firstAttribute="leading" secondItem="Epz-xU-9TM" secondAttribute="trailing" constant="8" symbolic="YES" id="wJ9-T1-rT8"/>
</constraints>
</view>
<point key="canvasLocation" x="-12.5" y="106.5"/>
</window>
</objects>
</document>

View File

@@ -44,6 +44,10 @@
* Command with placeholders and references resolved
*/
@property (nonatomic, readonly, copy) NSString *evaluatedCommand;
/**
@return command with placeholders and references resolved but masked password placeholder
*/
@property (nonatomic, readonly, copy) NSString *maskedEvaluatedCommand;
/**
* @return YES if valid, NO otherwise
*/

View File

@@ -26,6 +26,7 @@
@interface MPAutotypeContext () {
NSString *_evaluatedCommand;
NSString *_maskedEvaluatedCommand;
}
@end
@@ -69,6 +70,16 @@
return _evaluatedCommand;
}
- (NSString *)maskedEvaluatedCommand {
if(!_maskedEvaluatedCommand) {
NSString *passwordPlaceholder = [NSString stringWithFormat:@"{%@}",kKPKPasswordKey];
NSString *normalized = self.normalizedCommand;
NSString *masked = [normalized stringByReplacingOccurrencesOfString:passwordPlaceholder withString:@"•••••" options:NSCaseInsensitiveSearch range:NSMakeRange(0, normalized.length)];
_maskedEvaluatedCommand = [[masked kpk_finalValueForEntry:self.entry] copy];
}
return _maskedEvaluatedCommand;
}
- (NSString *)description {
return [NSString stringWithFormat:@"command:%@\nnormalized:%@\nevaluated:%@\nentry.title:%@\nentry.uuid:%@\n",
self.command,