Skip to content
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

Issue 49 summarize changes #136

Merged
merged 35 commits into from
Jun 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
60bed9f
Add quotes to shell cmd to encapsulate arg1
tparchambault May 18, 2021
d3e986c
Do not process paths containing whitespace.
tparchambault May 19, 2021
a0d403e
Merge branch 'master' into build
tparchambault May 19, 2021
ebcbd22
Fix pylint complaint with whitespace.
tparchambault May 19, 2021
5552278
Syncing branch with origin's version
tparchambault May 19, 2021
a7735b5
Fix flake8 errors
tparchambault May 19, 2021
484dc03
Add rejected file(s) list to dlg
tparchambault May 20, 2021
efd9578
fix flake8 linting error
tparchambault May 20, 2021
18e8841
Layout dialog text
tparchambault May 20, 2021
1f1c555
Add rejected files to the dialog
tparchambault May 20, 2021
4e179b4
Fix lint errors
tparchambault May 20, 2021
2b91fea
Merge branch 'master' into issue-49_summarize_changes
tparchambault May 25, 2021
7f7c39b
Intermediate dev ci: dialog w/embedded list working
tparchambault May 31, 2021
b68323a
Intermediate dev ci: dialog displays files
tparchambault Jun 2, 2021
b13e9b7
Synced w/master
tparchambault Jun 9, 2021
93cd765
Merge branch 'master' into issue-49_summarize_changes
tparchambault Jun 10, 2021
28c2839
Synced w/master
tparchambault Jun 10, 2021
60d21ed
Display changeset list when asking the user to confirm deployment
tparchambault Jun 10, 2021
e1e3a6d
Fix flake8/linting error
tparchambault Jun 10, 2021
151b3d1
Merge branch 'master' into issue-49_summarize_changes
tparchambault Jun 15, 2021
6ace0d3
Merge branch 'master' into issue-49_summarize_changes
tparchambault Jun 17, 2021
f690713
Intermediate dev CI.
tparchambault Jun 17, 2021
d7c2e2e
Add internationalization to new confirmation dlg.
tparchambault Jun 17, 2021
ad5a437
Fix flake8 linting errors
tparchambault Jun 17, 2021
d847949
Update lexical-core version
tparchambault Jun 17, 2021
534b8f7
Remove explicit lexical-core version
tparchambault Jun 18, 2021
ff39226
Merge branch 'master' into issue-49_summarize_changes
tparchambault Jun 18, 2021
03a0fc8
Fix failing CI UI tests
tparchambault Jun 18, 2021
fa243ef
Again fix failing CI UI tests
tparchambault Jun 18, 2021
59d6ae8
Rename confirm info dlg file, delete unused dlg file
tparchambault Jun 22, 2021
9df52be
change module name to support renamed confirm info dlg module
tparchambault Jun 22, 2021
0612f9c
Fix failing CI tests
tparchambault Jun 22, 2021
4e44876
Rename test file
tparchambault Jun 22, 2021
f465495
Rename method to consistent with functionality
tparchambault Jun 22, 2021
379ba64
Add unit test to confirm_info_dialog
tparchambault Jun 22, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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