Commit Graph

3936 Commits

Author SHA1 Message Date
Digimer
4aff8a1722 * Fixed bad calls to $an->_hostname and $an->_short_hostname.
Signed-off-by: Digimer <digimer@alteeve.ca>
2017-07-29 01:29:45 -04:00
Digimer
a932b44d28 * Fixed a few more problems with the SQL schema and setting up the database when needed.
* Fixed more typo-related bugs.
* Created System->enable_daemon().
* Changed the 'database::general' to 'sys::database' to avoid accidental collisions with database IDs.

Signed-off-by: Digimer <digimer@alteeve.ca>
2017-07-28 00:39:53 -04:00
Digimer
13352bad6d * Moved most of 'scancore-database' into the new Database->configure_pgsql() method. I had renamed that script, but now it will be removed soon.
* Created System->reload_daemon().

Signed-off-by: Digimer <digimer@alteeve.ca>
2017-07-27 01:56:52 -04:00
Digimer
ae58dd6f12 * This commit gets m3 back to being able to compile. It very likely doesn't actually work yet though.
* Added the variables table to the core SQL schema.
* Added Databsae->insert_or_update_variables() and ->read_variable().

Signed-off-by: Digimer <digimer@alteeve.ca>
2017-07-24 02:28:11 -04:00
Digimer
66a984adbc NOTE: Certainly a broken commit.
This continues the work of adding database support (and ancilliary functions) to m3.
* Adds Alert->check_alert_sent() and Alert->register_alert(), providing similar functions as in m2.
* Adds Database->disconnect(), Database->insert_or_update_states(), Database->locking() (still in progress), Database->mark_active(), Database->_find_behind_database(), Database->_mark_database_as_behind() and Database->_test_access().

Signed-off-by: Digimer <digimer@alteeve.ca>
2017-07-20 02:00:40 -04:00
Digimer
13ae1f1701 Some more work on the database (and related methods). Still a long way from working.
Signed-off-by: Digimer <digimer@alteeve.ca>
2017-07-10 02:58:55 -04:00
Digimer
3ea562a79c Note: Broken Commit
* This is an in-progress commit working on adding the Database methods. Much of it is copy/pasted from v2 and none of the new code is tested yet. It will certainly fail to compile.

Signed-off-by: Digimer <digimer@alteeve.ca>
2017-07-07 01:54:49 -04:00
Digimer
e3f782a60c * Finished getting the unit tests caught up with the AN::Tools module methods.
Signed-off-by: Digimer <digimer@alteeve.ca>
2017-06-24 20:24:45 -04:00
Digimer
6b5185fe61 * Added a lot more testing.
* Created Get->uuid to generate random UUIDs via 'uuidgen'.
* Created Storage->read_mode that returns the standard 4-digit mode of a directory or file.
* Created System->stop_daemon to stop daemons.
* Altered Template->get to take fully defined path names.
* Altered Template->skin to use the 'set' parameter (as documented) instead of 'skin'. Also made it so that a skin could be set even if the skin directory doesn't exist via the new 'fatal' parameter.

Signed-off-by: Digimer <digimer@alteeve.ca>
2017-06-22 22:57:51 -04:00
Digimer
367eb1a12f * Some more work done to testing.
Signed-off-by: Digimer <digimer@alteeve.ca>
2017-06-22 13:06:30 -04:00
Digimer
edf85511f4 * Did more work on Tools.t tests.
* Changed Log->secure and Log->level to take new settings using 'set => X' parameter to bring them inline with other modules.

Signed-off-by: Digimer <digimer@alteeve.ca>
2017-06-21 20:09:22 -04:00
Digimer
642e162395 * Added a bunch of tests to Tools.t, though many more tests still to add.
* Fixed a couple of bugs in sanity-checking input data in Convert->cidr().
* Created Get->is_ipv4 to validate IPv4 addresses.

Signed-off-by: Digimer <digimer@alteeve.ca>
2017-06-21 00:31:41 -04:00
Digimer
648af130cd * Finished scancore-database. It now setups/repairs postgresql database config, user and scancore database.
* Fixed a bug in Tools.pm->_set_paths where a path set to '#!not_found!#' was being set (the existing value should have been left alone).
* Fixed some escaping in Log->entry. Also added some additional checks to error more gracefully.
* Created Storage->copy_file() that, well, copies files.
* Fixed Storage->find to not call Log->entry.
* Fixed Storage->make_directory() to only pass the first digit when passed a GID or UID with more that one digit (as can happen with GIDs).
* Updated Storage->write_file() to take 'secure' as a parameter to treat the file contents as containing secure data for logging purposes.
* Created System->check_daemon and ->start_daemon to check and start systemd daemons, as needed.
* Updated scancore-daemon to support running things just once on invocation (effectively run on boot or daemon restart). Call scancore-database. from here.
* Added reading striker.conf to scancore-update-states.

Signed-off-by: Digimer <digimer@alteeve.ca>
2017-06-19 22:32:35 -04:00
Digimer
632f677f04 * Added two new modules; Convert.pm for converting data types and Database.pm for managing all things related to databases.
* Created Convert->cidr() that will convert dotted decimal subnets to CIDR notation and vice versa.
* Created Database->get_local_id that returns the ID from striker.conf that matches the local host, if any,
* Created Get->network_details that returns the host name and a list of interfaces and their IP addresses (if any).
* Created System->call() that takes a shell call and returns the output.
* Created icon for the top-right bar that are "on" (lit up).
* Created a skeleton striker.conf file.
* Created the new scancore-database tool that will manage ScanCore databases.

Signed-off-by: Digimer <digimer@alteeve.ca>
2017-06-13 17:08:38 -04:00
Digimer
f948d7a762 * Updated Log->entry() to escape the finished string just prior to calling logger.
* Updated Template->get() to set the skin directory more cleanly.
* Updated Words->string() to check for a string with #!variable!x!# replacement keys and the 'variables' parameter wasn't passed and throws a useful error are returns '#!error!#'.
* Added top-right icons (see sources.txt for attributions).
* Created a new shared.html template file for shared templates, and added a template for the HTML header.

Signed-off-by: Digimer <digimer@alteeve.ca>
2017-06-13 11:09:21 -04:00
Digimer
e983f27de7 * Changed scancore-update-states to report link speeds > 100 Gbps as 0.
* Added polling to update the network state as needed.

Signed-off-by: Digimer <digimer@alteeve.ca>
2017-06-12 17:39:09 -04:00
Digimer
f7616e4bb6 * Fixed my fix to use data in the elements instead of divs, so the data doesn't show on the page.
Signed-off-by: Digimer <digimer@alteeve.ca>
2017-06-12 15:58:19 -04:00
Digimer
a8a98b431d * Updated the jquery to read in translated strings and to display the link speed.
Signed-off-by: Digimer <digimer@alteeve.ca>
2017-06-12 15:44:23 -04:00
Digimer
8c42b78e63 * Made some progress on displaying the network state on an HTML page using jquery. It's ugly as sin, but it works.
* Fixed a bug in Storage->write_file() where the parent directory wasn't created if it was missing. Also removed passing the mode to the parent directory creation as the file mode rarely applies to the directory (ie: 644 breaks directories but is common for files).
* Changed Template->skin to return just the skin name, not the path.
* Updated scancore-update-states to write the network state information to both xml (for ScanCore) and JSON (for jquery) files.

Signed-off-by: Digimer <digimer@alteeve.ca>
2017-06-12 14:39:20 -04:00
Digimer
bea6bc5e69 * Updated Tools->new() to check if it is being invoked in a browser and set the environment appropriately. It also sets the PWD environmental variable to the DOCUMENT_ROOT variable.
* Renamed 'defaults::languages' to 'defaults::language'.
* Created Storage->change_mode(), Storage->change_owner(), Storage->make_directory() and Storage->write_file() that does what their names imply, using the shell commands instead of the built-in commands (may switch to them later). The ->make_directory() method will create any needed parent directories.
* Moved System->read_file() to the Storage module as it made more sense there. For now, System is empty.
* Created Words->language to set or check the active output language.
* Fixed Template->get() to use Words->language.
* Updated Words->string() to take the new 'string' parameter which, when set, is used instead of the 'key' parameter and is treated as a pre-retrieved string, so replacement keys are directly injected.
* Updated Template->get() to take the 'variables' parameter and then uses Words->string({string => ...}) to process the replacement keys.
* Updated tools/scancore-update-states to write out the network interface states to the status.xml file.

Signed-off-by: Digimer <digimer@alteeve.ca>
2017-06-11 03:00:35 -04:00
Digimer
f93f8a10e5 * Fixed the scancore-daemon.service unit file.
Signed-off-by: Digimer <digimer@alteeve.ca>
2017-06-10 02:54:28 -04:00
Digimer
753d7a3ba6 * Created the new System.pm module with the initial read_file() method that reads files.
* Created Log->language that sets/returns the active log language.
* Created Log->variables that takes a hash reference and logs their variable: [$value] pairs.
* Created the new /usr/sbin/striker/ directory which is added to the list of search directories. We will store our tools here.
* Created the scancore-daemon and scancore-daemon.unit files which will handle all the things we used to use crontab for, minus ScanCore itself.
* Created the scancore-update-states that will eventually store some machine state information in a file that the web browser can read.
* Created the cgi-bin/home script that will be the main landing page for the Striker UI.
* Added some of the initial html files.

Signed-off-by: Digimer <digimer@alteeve.ca>
2017-06-10 02:38:04 -04:00
Digimer
e49d5285c0 * Added the AN/test.conf file needed for Tools.t and added testing for the new Get, Log and Validate methods (save for Get->switches or Log->entry as I am not sure how to test them yet).
Signed-off-by: Digimer <digimer@alteeve.ca>
2017-06-09 14:52:56 -04:00
Digimer
0ee84cd31e * Created the new Templates module to handle reading and preparing templates.
* Added an index.html and favicon as well as a very basic 'home' cgi script which will allow the web development to start.

Signed-off-by: Digimer <digimer@alteeve.ca>
2017-06-09 04:29:25 -04:00
Digimer
b571fa043e * Created Validate.pm and created Validate->is_uuid for validating UUID strings.
Signed-off-by: Digimer <digimer@alteeve.ca>
2017-06-08 01:30:28 +09:00
Digimer
0a712f4a9c * Added Get->switches to read in command line switches.
* Added Get->host_uuid that reads the host's UUID from dmidecode.
* Added Log->_adjust_log_level to automatically change the active log level when -V (0), -v (1), -vv (2), -vvv (3) or -vvvv (4) are passed.

Signed-off-by: Digimer <digimer@alteeve.ca>
2017-06-08 01:15:03 +09:00
Digimer
421d970f22 * Added the new 'tools.conf' which can be used to override AN::Tools default values.
* Got Log->entry() working now. Decided to use journald logging exclusively... They've thought a lot more about logging than we will, and the idea that there are special facilities for sensitive log entries and the ability to perform remote logging was too appealing.
* Created Log->level() to set/check the currently active log level.
* Created Log->secure() to set/check whether sensitive log entries will be recorded.

Signed-off-by: Digimer <digimer@alteeve.ca>
2017-06-08 00:36:06 +09:00
Digimer
dd4fb49e6c * Added the new AN::Log and AN::Get modules.
* Added Get->date_and_time() method.
* Added the 'initialize' parameter to Storage->search_directories() to have a cleaner way of initializing the search directories.

Signed-off-by: Digimer <digimer@alteeve.ca>
2017-06-05 21:02:14 +09:00
Digimer
7b8cb22de0 * Fixed the initial call to Storage->search_directories() in AN::Tools->new() to properly prep the search directory list.
* Added tests for the new Words->string() method.

Signed-off-by: Digimer <digimer@alteeve.ca>
2017-06-05 11:48:13 +09:00
Digimer
a844136c3b * Added the new Words->string() method to insert variables, data and other strings into the requested 'key'. This is a condensed and cleaned up version of v2's String->get() method.
* Added the new $an->_get_hash_reference() method that takes a key in the format "foo::bar" and returns the contents of $an->data->{foo}{bar}.
* Added the new Words->clean_spaces() method that removes leading and trailing spaces from a string, and condenses multiple spaces into single ones to simplify string parsing.

Signed-off-by: Digimer <digimer@alteeve.ca>
2017-06-04 13:40:17 +09:00
Digimer
dab7b17517 * Fixed the double-encoding messages when using XML::Simple to read in words files. Our use for XML is simple, so despite XML::Simple being discouraged, it suits our needs well.
* Created tests for most existing module methods now.
* Updated Storage->search_directories to handle merging @INC and $ENV{'PATH'} when called with an invalid directories parameter, and exploited this behaviour to initially set the directory search list. This also deprecated the Tools->_add_environment_path_to_search_directories() method.
* Added Storage->read_config based on the old v2 'Storage->read_conf()'. Also ported over the old Tools->_add_hash_reference() and Tools->_make_hash_reference() methods to assist with this method's operation.
* Created Words->key() that returns the raw string for a given language and key.

Signed-off-by: Digimer <digimer@alteeve.ca>
2017-05-27 14:23:34 +09:00
Digimer
ec307bc019 * Working on a new way of handling words files.
Signed-off-by: Digimer <digimer@alteeve.ca>
2017-05-10 15:01:36 -04:00
Digimer
4ac37e239f * Added the new AN::Tools::Storage and ::Alert modules (basic as they are at this point)..
* Created AN/Tools.t for testing.

Signed-off-by: Digimer <digimer@alteeve.ca>
2017-05-02 00:41:12 -04:00
Digimer
8605007af9 * Added the initial AN::Tools perl module. It is exceedingly basic at this stage.
Signed-off-by: Digimer <digimer@alteeve.ca>
2017-04-13 17:04:03 -04:00
Digimer
a59ffe40e1 Updated the README to be somewhat more descriptive.
Signed-off-by: Digimer <digimer@alteeve.ca>
2017-04-12 23:49:35 -04:00
Digimer
7978a83bca first commit 2017-04-12 23:46:49 -04:00