Skip to content

Commit

Permalink
Issue 49 summarize changes (#136)
Browse files Browse the repository at this point in the history
* Add quotes to shell cmd to encapsulate arg1

* Do not process paths containing whitespace.

* Fix pylint complaint with whitespace.

* Fix flake8 errors

* Add rejected file(s) list to dlg

* fix flake8 linting error

* Layout dialog text

* Add rejected files to the dialog

* Fix lint errors

* Intermediate dev ci: dialog w/embedded list working

* Intermediate dev ci: dialog displays files

* Synced w/master

* Display changeset list when asking the user to confirm deployment

* Fix flake8/linting error

* Intermediate dev CI.

* Add internationalization to new confirmation dlg.

* Fix flake8 linting errors

* Update lexical-core version

* Remove explicit lexical-core version

* Fix failing CI UI tests

* Again fix failing CI UI tests

* Rename confirm info dlg file, delete unused dlg file

* change module name to support renamed confirm info dlg module

* Fix failing CI tests

* Rename test file

* Rename method to consistent with functionality

* Add unit test to confirm_info_dialog
  • Loading branch information
tparchambault authored Jun 23, 2021
1 parent df3a71f commit 64cacca
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 93 deletions.
80 changes: 46 additions & 34 deletions python/fapolicy_analyzer/locale/fapolicy_analyzer.pot
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: fapolicy-analyzer 0.0.4\n"
"Project-Id-Version: fapolicy-analyzer snapshot\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2021-05-26 11:27-0400\n"
"POT-Creation-Date: 2021-06-17 14:42-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -48,138 +48,150 @@ msgid ""
" This will update the fapolicy trust and restart the service."
msgstr ""

#: fapolicy_analyzer/ui/strings.py:8
msgid "Action"
msgstr ""

#: fapolicy_analyzer/ui/strings.py:9
msgid "File Path"
msgstr ""

#: fapolicy_analyzer/ui/strings.py:11
msgid "This file is trusted."
msgstr ""

#: fapolicy_analyzer/ui/strings.py:10
#: fapolicy_analyzer/ui/strings.py:12
msgid "There is a discrepancy with this file."
msgstr ""

#: fapolicy_analyzer/ui/strings.py:11
#: fapolicy_analyzer/ui/strings.py:13
msgid "The trust status of this file is unknown."
msgstr ""

#: fapolicy_analyzer/ui/strings.py:13
#: fapolicy_analyzer/ui/strings.py:15
msgid "System Trust Database"
msgstr ""

#: fapolicy_analyzer/ui/strings.py:14
#: fapolicy_analyzer/ui/strings.py:16
msgid "Ancillary Trust Database"
msgstr ""

#: fapolicy_analyzer/ui/strings.py:16
#: glade/ancillary_trust_database_admin.glade:50
#: fapolicy_analyzer/glade/ancillary_trust_database_admin.glade:50
#: fapolicy_analyzer/ui/strings.py:18
msgid "Trust"
msgstr ""

#: fapolicy_analyzer/ui/strings.py:17
#: fapolicy_analyzer/ui/strings.py:19
msgid "File"
msgstr ""

#: fapolicy_analyzer/ui/strings.py:19
#: fapolicy_analyzer/ui/strings.py:21
msgid "Add File"
msgstr ""

#: fapolicy_analyzer/ui/strings.py:21
#: fapolicy_analyzer/ui/strings.py:23
msgid "File path(s) contains embedded whitespace."
msgstr ""

#: fapolicy_analyzer/ui/strings.py:22
#: fapolicy_analyzer/ui/strings.py:24
msgid ""
"fapolicyd currently does not support paths containing spaces. The "
"following paths will not be added to the Trusted Files List.\n"
"(fapolicyd: V TBD)\n"
"\n"
msgstr ""

#: glade/analyzer_selection_dialog.glade:25
#: fapolicy_analyzer/glade/analyzer_selection_dialog.glade:25
msgid "Scan System"
msgstr ""

#: glade/analyzer_selection_dialog.glade:39
#: fapolicy_analyzer/glade/analyzer_selection_dialog.glade:39
msgid "Administer Trust Databases"
msgstr ""

#: glade/analyzer_selection_dialog.glade:61
#: fapolicy_analyzer/glade/analyzer_selection_dialog.glade:61
msgid "Analyzer Selection"
msgstr ""

#: glade/analyzer_selection_dialog.glade:94
#: fapolicy_analyzer/glade/analyzer_selection_dialog.glade:94
msgid "Analyze From Audit"
msgstr ""

#: glade/ancillary_trust_database_admin.glade:65
#: fapolicy_analyzer/glade/ancillary_trust_database_admin.glade:65
msgid "Untrust"
msgstr ""

#: glade/ancillary_trust_database_admin.glade:102
#: fapolicy_analyzer/glade/ancillary_trust_database_admin.glade:102
msgid "Deploy Ancillary Trust"
msgstr ""

#: glade/deploy_confirm_dialog.glade:10
#: fapolicy_analyzer/glade/deploy_confirm_dialog.glade:10
msgid "Keep these trust changes?"
msgstr ""

#: glade/deploy_confirm_dialog.glade:11
#: fapolicy_analyzer/glade/deploy_confirm_dialog.glade:11
msgid "Reverting to previous settings in 15 seconds."
msgstr ""

#: glade/main_window.glade:7
#: fapolicy_analyzer/glade/main_window.glade:7
msgid "About File Acccess Policy Analyzer"
msgstr ""

#: glade/main_window.glade:54
#: fapolicy_analyzer/glade/main_window.glade:54
msgid "File Access Policy Analyzer"
msgstr ""

#: glade/main_window.glade:73
#: fapolicy_analyzer/glade/main_window.glade:77
msgid "_File"
msgstr ""

#: glade/main_window.glade:97
#: fapolicy_analyzer/glade/main_window.glade:101
msgid "_Help"
msgstr ""

#: glade/system_trust_database_admin.glade:44
#: fapolicy_analyzer/glade/notification.glade:29
msgid "x"
msgstr ""

#: fapolicy_analyzer/glade/system_trust_database_admin.glade:44
msgid "Add File To Ancillary Trust Database"
msgstr ""

#: glade/trust_file_details.glade:41
#: fapolicy_analyzer/glade/trust_file_details.glade:41
msgid "In Database"
msgstr ""

#: glade/trust_file_details.glade:81
#: fapolicy_analyzer/glade/trust_file_details.glade:81
msgid "On File System"
msgstr ""

#: glade/trust_file_details.glade:120
#: fapolicy_analyzer/glade/trust_file_details.glade:120
msgid "File Trust Status"
msgstr ""

#: glade/trust_file_list.glade:75
#: fapolicy_analyzer/glade/trust_file_list.glade:75
msgid "page0"
msgstr ""

#: glade/trust_file_list.glade:102
#: fapolicy_analyzer/glade/trust_file_list.glade:102
msgid "Loading..."
msgstr ""

#: glade/trust_file_list.glade:117
#: fapolicy_analyzer/glade/trust_file_list.glade:117
msgid "page1"
msgstr ""

#: glade/unapplied_changes_dialog.glade:8
#: fapolicy_analyzer/glade/unapplied_changes_dialog.glade:8
msgid "Unapplied Changes"
msgstr ""

#: glade/unapplied_changes_dialog.glade:15
#: fapolicy_analyzer/glade/unapplied_changes_dialog.glade:15
msgid ""
"\n"
"There are unapplied changes."
msgstr ""

#: glade/unapplied_changes_dialog.glade:16
#: fapolicy_analyzer/glade/unapplied_changes_dialog.glade:16
msgid "Your changes will be lost."
msgstr ""

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def confirm_dialog(confirm_resp, mocker):
run=MagicMock(return_value=confirm_resp), hide=MagicMock()
)
mocker.patch(
"ui.ancillary_trust_database_admin.ConfirmDialog.get_content",
"ui.ancillary_trust_database_admin.ConfirmInfoDialog",
return_value=mock_confirm_dialog,
)
return mock_confirm_dialog
Expand Down
40 changes: 40 additions & 0 deletions python/fapolicy_analyzer/tests/test_confirm_info_dialog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import context # noqa: F401
import gi

gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
from helpers import delayed_gui_action
from ui.confirm_info_dialog import ConfirmInfoDialog


def test_creates_widget():
widget = ConfirmInfoDialog()
assert type(widget) is ConfirmInfoDialog


def test_adds_dialog_to_parent():
parent = Gtk.Window()
widget = ConfirmInfoDialog(parent=parent)
assert widget.get_transient_for() == parent


def test_dialog_actions_responses():
dialog = ConfirmInfoDialog()
for expected in [Gtk.ResponseType.YES, Gtk.ResponseType.NO]:
button = dialog.get_widget_for_response(expected)
delayed_gui_action(button.clicked, delay=5)
response = dialog.run()
assert response == expected


def test_load_path_action_list():
parent = Gtk.Window()
widget = ConfirmInfoDialog(parent=parent)

path_action_list = [("/tmp/fu.txt", "Add"), ("/tmp/bar.txt", "Del")]
widget.load_path_action_list(path_action_list)

# Verify the contents of the ConfirmInfoDialog.ListStore
for i, j in zip(widget.changeStore, range(2)):
# Note: tuples are reversed when loading Gtk.ListStore for display
assert((i[1], i[0]) == path_action_list[j])
27 changes: 0 additions & 27 deletions python/fapolicy_analyzer/tests/test_confirmation_dialog.py

This file was deleted.

14 changes: 6 additions & 8 deletions python/fapolicy_analyzer/ui/ancillary_trust_database_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
from .ui_widget import UIWidget
from .trust_file_list import TrustFileList
from .trust_file_details import TrustFileDetails
from .confirmation_dialog import ConfirmDialog
from .deploy_confirm_dialog import DeployConfirmDialog
from .configs import Colors
from .state_manager import stateManager, NotificationType
from .confirm_info_dialog import ConfirmInfoDialog


class AncillaryTrustDatabaseAdmin(UIWidget):
Expand Down Expand Up @@ -138,13 +138,11 @@ def on_deployBtn_clicked(self, *args):
# element integration
print(listPathActionTuples)
parent = self.content.get_toplevel()
confirmDialog = ConfirmDialog(
strings.DEPLOY_ANCILLARY_CONFIRM_DIALOG_TITLE,
strings.DEPLOY_ANCILLARY_CONFIRM_DIALOG_TEXT,
parent,
).get_content()
confirm_resp = confirmDialog.run()
confirmDialog.hide()
dlgDeployList = ConfirmInfoDialog(parent)
dlgDeployList.load_path_action_list(stateManager.get_path_action_list())
confirm_resp = dlgDeployList.run()
dlgDeployList.hide()

if confirm_resp == Gtk.ResponseType.YES:
try:
self.system.deploy()
Expand Down
52 changes: 52 additions & 0 deletions python/fapolicy_analyzer/ui/confirm_info_dialog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
import ui.strings as strings


class ConfirmInfoDialog(Gtk.Dialog):
def __init__(self, parent=None):
Gtk.Dialog.__init__(self, strings.DEPLOY_ANCILLARY_CONFIRM_DIALOG_TITLE,
transient_for=parent, flags=0)

self.add_buttons(Gtk.STOCK_NO,
Gtk.ResponseType.NO,
Gtk.STOCK_YES,
Gtk.ResponseType.YES)

self.set_default_size(-1, 200)

label = Gtk.Label(label=strings.DEPLOY_ANCILLARY_CONFIRM_DIALOG_TEXT)

self.scrolled_window = Gtk.ScrolledWindow()
self.changeStore = Gtk.ListStore(str, str)
self.tree_view = Gtk.TreeView(model=self.changeStore)

cellAction = Gtk.CellRendererText()
cellAction.set_property("background", "light gray")
columnAction = Gtk.TreeViewColumn(strings.DEPLOY_ANCILLARY_CONFIRM_DLG_ACTION_COL_HDR,
cellAction, markup=0)
self.tree_view.append_column(columnAction)
columnAction.set_sort_column_id(0)

cellFile = Gtk.CellRendererText()
columnFile = Gtk.TreeViewColumn(strings.DEPLOY_ANCILLARY_CONFIRM_DLG_PATH_COL_HDR,
cellFile, text=1)

self.tree_view.append_column(columnFile)
columnFile.set_sort_column_id(1)
self.scrolled_window.add(self.tree_view)
self.scrolled_window.set_policy(Gtk.PolicyType.NEVER,
Gtk.PolicyType.ALWAYS)

box = self.get_content_area()
box.add(label)
box.pack_start(self.scrolled_window, True, True, 0)

self.show_all()

def load_path_action_list(self, listPathActionPairs):
if listPathActionPairs:
for e in listPathActionPairs:
# tuples are in (path,action) order, displayed as (action,path)
self.changeStore.append(e[::-1])
23 changes: 0 additions & 23 deletions python/fapolicy_analyzer/ui/confirmation_dialog.py

This file was deleted.

2 changes: 2 additions & 0 deletions python/fapolicy_analyzer/ui/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"""Are you sure you wish to deploy your changes to the ancillary trust database?
This will update the fapolicy trust and restart the service."""
)
DEPLOY_ANCILLARY_CONFIRM_DLG_ACTION_COL_HDR = _("Action")
DEPLOY_ANCILLARY_CONFIRM_DLG_PATH_COL_HDR = _("File Path")

TRUSTED_FILE_MESSAGE = _("This file is trusted.")
DISCREPANCY_FILE_MESSAGE = _("There is a discrepancy with this file.")
Expand Down

0 comments on commit 64cacca

Please sign in to comment.