diff --git a/CHANGELOG.md b/CHANGELOG.md index 8251ae3a..b5ca474e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,26 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.13.0] - August 2023 + +### Added + +* Added functionality to opt out of Anonymized Data Reporting before deploying the solution + +### Changed + +* Updated Cloudfront distribution to L2 construct in browser stack + +### Fixed + +* #379 Fixed VPC inputs from throwing an exception when the Source is an Entitlement and there is a VPC Interface attached that is used for output only +* #380 Add missing f-string prefix +* #381 Add empty Tags to ec2 node if none returned from service + +### Removed + +* Removed fuzzywuzzy library and replaced its usage with built-in python functions + ## [1.12.0] - May 2023 ### Added diff --git a/NOTICE.txt b/NOTICE.txt index 0f353837..ca932ef0 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -1302,348 +1302,3 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - ------ - -** fuzzywuzzy; version 0.18.0 -- https://github.com/seatgeek/fuzzywuzzy - -GNU GENERAL PUBLIC LICENSE -Version 2, June 1991 - -Copyright (C) 1989, 1991 Free Software Foundation, Inc. -51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Everyone is permitted to copy and distribute verbatim copies -of this license document, but changing it is not allowed. - -Preamble - -The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - -When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - -To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - -For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - -We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - -Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - -Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - -The precise terms and conditions for copying, distribution and -modification follow. - -GNU GENERAL PUBLIC LICENSE -TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - -0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - -1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - -2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - -a) You must cause the modified files to carry prominent notices -stating that you changed the files and the date of any change. - -b) You must cause any work that you distribute or publish, that in -whole or in part contains or is derived from the Program or any -part thereof, to be licensed as a whole at no charge to all third -parties under the terms of this License. - -c) If the modified program normally reads commands interactively -when run, you must cause it, when started running for such -interactive use in the most ordinary way, to print or display an -announcement including an appropriate copyright notice and a -notice that there is no warranty (or else, saying that you provide -a warranty) and that users may redistribute the program under -these conditions, and telling the user how to view a copy of this -License. (Exception: if the Program itself is interactive but -does not normally print such an announcement, your work based on -the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - -3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - -a) Accompany it with the complete corresponding machine-readable -source code, which must be distributed under the terms of Sections -1 and 2 above on a medium customarily used for software interchange; or, - -b) Accompany it with a written offer, valid for at least three -years, to give any third party, for a charge no more than your -cost of physically performing source distribution, a complete -machine-readable copy of the corresponding source code, to be -distributed under the terms of Sections 1 and 2 above on a medium -customarily used for software interchange; or, - -c) Accompany it with the information you received as to the offer -to distribute corresponding source code. (This alternative is -allowed only for noncommercial distribution and only if you -received the program in object code or executable form with such -an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - -4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - -5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - -6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - -7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - -8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - -9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - -10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - -NO WARRANTY - -11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - -12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - -END OF TERMS AND CONDITIONS - -How to Apply These Terms to Your New Programs - -If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - -To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - -Copyright (C) - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - -Gnomovision version 69, Copyright (C) year name of author -Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. -This is free software, and you are welcome to redistribute it -under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - -Yoyodyne, Inc., hereby disclaims all copyright interest in the program -`Gnomovision' (which makes passes at compilers) written by James Hacker. - -, 1 April 1989 -Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/README.md b/README.md index cffc9ba1..6bd03005 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,8 @@ Note: If you want to use the solution without building from source, navigate to - [Deploy](#deploy) - [File structure](#file-structure) - [License](#license) +- [Collection of operational metrics](#collection-of-operational-metrics) - [Navigate](#navigate) -- [Anonymous Metrics](#metrics) # Solution Overview @@ -170,9 +170,9 @@ See license [here](LICENSE.txt). -# Anonymous Metrics +# Collection of operational metrics -This solution collects anonymous operational metrics to help AWS improve the quality of features of the solution. For more information about this capability, please see the [Install Guide](https://docs.aws.amazon.com/solutions/latest/media-services-application-mapper/collection-of-operational-metrics.html) for details on the data sent, and how to enable and disable this capability. +This solution collects anonymized operational metrics to help AWS improve the quality of features of the solution. For more information about this capability, please see the [implementation guide](https://docs.aws.amazon.com/solutions/latest/media-services-application-mapper-on-aws/references.html). ## Navigate Navigate to [Architecture](https://docs.aws.amazon.com/solutions/latest/media-services-application-mapper/architecture-overview.html) | [Workshop](docs/WORKSHOP.md) | [Install](https://docs.aws.amazon.com/solutions/latest/media-services-application-mapper/automated-deployment.html) | [Usage](https://docs.aws.amazon.com/solutions/latest/media-services-application-mapper/using-the-browser-application.html) | [Uninstall](https://docs.aws.amazon.com/solutions/latest/media-services-application-mapper/uninstall-the-solution.html) | [Rest API](docs/REST_API.md) | [Contributing](CONTRIBUTING.md) \ No newline at end of file diff --git a/THIRD-PARTY-LICENSES.txt b/THIRD-PARTY-LICENSES.txt index 025fd5d4..924f5eba 100644 --- a/THIRD-PARTY-LICENSES.txt +++ b/THIRD-PARTY-LICENSES.txt @@ -1287,348 +1287,3 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - ------ - -** fuzzywuzzy; version 0.18.0 -- https://github.com/seatgeek/fuzzywuzzy - -GNU GENERAL PUBLIC LICENSE -Version 2, June 1991 - -Copyright (C) 1989, 1991 Free Software Foundation, Inc. -51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Everyone is permitted to copy and distribute verbatim copies -of this license document, but changing it is not allowed. - -Preamble - -The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - -When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - -To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - -For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - -We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - -Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - -Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - -The precise terms and conditions for copying, distribution and -modification follow. - -GNU GENERAL PUBLIC LICENSE -TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - -0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - -1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - -2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - -a) You must cause the modified files to carry prominent notices -stating that you changed the files and the date of any change. - -b) You must cause any work that you distribute or publish, that in -whole or in part contains or is derived from the Program or any -part thereof, to be licensed as a whole at no charge to all third -parties under the terms of this License. - -c) If the modified program normally reads commands interactively -when run, you must cause it, when started running for such -interactive use in the most ordinary way, to print or display an -announcement including an appropriate copyright notice and a -notice that there is no warranty (or else, saying that you provide -a warranty) and that users may redistribute the program under -these conditions, and telling the user how to view a copy of this -License. (Exception: if the Program itself is interactive but -does not normally print such an announcement, your work based on -the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - -3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - -a) Accompany it with the complete corresponding machine-readable -source code, which must be distributed under the terms of Sections -1 and 2 above on a medium customarily used for software interchange; or, - -b) Accompany it with a written offer, valid for at least three -years, to give any third party, for a charge no more than your -cost of physically performing source distribution, a complete -machine-readable copy of the corresponding source code, to be -distributed under the terms of Sections 1 and 2 above on a medium -customarily used for software interchange; or, - -c) Accompany it with the information you received as to the offer -to distribute corresponding source code. (This alternative is -allowed only for noncommercial distribution and only if you -received the program in object code or executable form with such -an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - -4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - -5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - -6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - -7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - -8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - -9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - -10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - -NO WARRANTY - -11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - -12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - -END OF TERMS AND CONDITIONS - -How to Apply These Terms to Your New Programs - -If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - -To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - -Copyright (C) - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - -Gnomovision version 69, Copyright (C) year name of author -Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. -This is free software, and you are welcome to redistribute it -under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - -Yoyodyne, Inc., hereby disclaims all copyright interest in the program -`Gnomovision' (which makes passes at compilers) written by James Hacker. - -, 1 April 1989 -Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/deployment/cdk-solution-helper/index.js b/deployment/cdk-solution-helper/index.js index d631c10c..62bc38cd 100755 --- a/deployment/cdk-solution-helper/index.js +++ b/deployment/cdk-solution-helper/index.js @@ -46,7 +46,7 @@ fs.readdirSync(global_s3_assets).forEach((file) => { if (file === 'msam-core-release.template') { // Manually add the API Gateway Stage dependency // The API Gateway Stage is generated dynamically in SAM templates, - // therefore the stage is not visible toCDK when synthesizing the template + // therefore the stage is not visible to CDK when synthesizing the template // and throws an exception. const [usagePlanKey] = Object.keys(resources).filter(key => /UsagePlan[A-Z\d]{8}/.test(key)); resources[usagePlanKey].DependsOn = 'RestAPImsamStage'; @@ -56,6 +56,12 @@ fs.readdirSync(global_s3_assets).forEach((file) => { }, Stage: 'msam', }]; + + // Add AWS:LanguageExtensions Transform to support intrinsic functions + // See https://github.com/aws/serverless-application-model/issues/2533 for more details + if (typeof template.Transform === 'string') { + template.Transform = ['AWS::LanguageExtensions', template.Transform] + } } // Remove unnecessary CDK metadata diff --git a/deployment/requirements.txt b/deployment/requirements.txt index 0cd6a10e..a1e4906c 100644 --- a/deployment/requirements.txt +++ b/deployment/requirements.txt @@ -5,7 +5,6 @@ botocore cfn-lint crhelper defusedxml -fuzzywuzzy jsonpath_ng pylint requests diff --git a/source/cdk/lib/media-services-application-mapper.ts b/source/cdk/lib/media-services-application-mapper.ts index e864acb3..8ba6e9f9 100644 --- a/source/cdk/lib/media-services-application-mapper.ts +++ b/source/cdk/lib/media-services-application-mapper.ts @@ -39,6 +39,17 @@ export class MediaServicesApplicationMapper extends Stack { constraintDescription: 'Please enter a value for this field.', }); + /** + * Cfn Mapping + */ + utils.createCfnMapping(this, 'AnonymizedData', { + mapping: { + SendAnonymizedData: { + Data: 'Yes', + }, + }, + }); + /** * Nested Stacks */ @@ -84,6 +95,9 @@ export class MediaServicesApplicationMapper extends Stack { NotesTableName: dynamoDBModuleStack.NotesTable, CacheItemTTL: cacheItemTTL.valueAsString, RootStackName: Aws.STACK_NAME, + parameters: { + SendAnonymizedData: Fn.findInMap('AnonymizedData', 'SendAnonymizedData', 'Data'), + }, }); utils.addTemplateUrl( coreModuleStack, diff --git a/source/cdk/lib/msam-browser-app.ts b/source/cdk/lib/msam-browser-app.ts index 883ada8e..fd15d401 100644 --- a/source/cdk/lib/msam-browser-app.ts +++ b/source/cdk/lib/msam-browser-app.ts @@ -4,6 +4,7 @@ import { Aws, aws_cloudfront as cloudfront, + aws_cloudfront_origins as origins, aws_iam as iam, aws_lambda as lambda, aws_s3 as s3, @@ -91,114 +92,42 @@ export class MsamBrowserApp extends NestedStack { Aws.REGION, ]); - // CloudFront OriginAccessIdentity - const cloudfrontOriginAccessIdentity = new cloudfront.OriginAccessIdentity(this, 'MSAMAppBucketOriginAccessIdentity', { + // CloudFront Distribution + const cloudfrontDistribution = new cloudfront.Distribution(this, 'MSAMAppBucketCloudFrontDistribution', { + enabled: true, + defaultBehavior: { + origin: new origins.S3Origin(s3BucketBrowserApp), + viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.HTTPS_ONLY, + cachePolicy: new cloudfront.CachePolicy(this, 'MSAMAppBucketCloudFrontCachePolicy', { + minTtl: Duration.seconds(3600), + defaultTtl: Duration.seconds(7200), + maxTtl: Duration.seconds(86400), + headerBehavior: cloudfront.CacheHeaderBehavior.allowList( + 'Origin', + 'Access-Control-Request-Method', + 'Access-Control-Request-Headers', + ), + queryStringBehavior: cloudfront.CacheQueryStringBehavior.none(), + }), + allowedMethods: cloudfront.AllowedMethods.ALLOW_GET_HEAD_OPTIONS, + cachedMethods: cloudfront.CachedMethods.CACHE_GET_HEAD_OPTIONS, + compress: true, + }, comment: Fn.join('', [ - 'Origin Access Identity for ', + 'CDN for ', s3BucketBrowserApp.bucketName, - ]) + ]), + defaultRootObject: 'index.html', + priceClass: cloudfront.PriceClass.PRICE_CLASS_ALL, + minimumProtocolVersion: cloudfront.SecurityPolicyProtocol.TLS_V1_2_2019, + enableLogging: true, + logBucket: s3BucketbrowserAppLogs, + logFilePrefix: 'cloudfront/', }); - // Browser App S3 Bucket Policy - const s3BucketAppPolicy = this.createS3BucketPolicy('MSAMBrowserAppBucketPolicy', { - bucket: s3BucketBrowserApp.bucketName, - policyDocument: new iam.PolicyDocument({ - statements: [ - new iam.PolicyStatement({ - effect: iam.Effect.ALLOW, - principals: [new iam.CanonicalUserPrincipal(cloudfrontOriginAccessIdentity.cloudFrontOriginAccessIdentityS3CanonicalUserId)], - actions: ['s3:GetObject'], - resources: [ - Fn.join('', [ - s3BucketBrowserApp.bucketArn, - '/*', - ]), - ], - }), - ], - }), - }); - - utils.setNagSuppressRules(s3BucketAppPolicy, - { - id: 'AwsSolutions-S10', - reason: 'HTTPS requirement not supported at this time.', - } - ) - - // CloudFront Distribution - /** - * Distribution L2 construct is available for use - * The solution, however, requires many cloudfront propeties not supported in L2 construct's native props - * Thus, the L1 CfnCloudfront is used instead. - */ - const cloudfrontDistribution = new cloudfront.CfnDistribution(this, 'MSAMAppBucketCloudFrontDistribution', { - distributionConfig: { - comment: Fn.join('', [ - 'CDN for ', - s3BucketBrowserApp.bucketName, - ]), - defaultCacheBehavior: { - targetOriginId: s3BucketBrowserApp.bucketName, - viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.HTTPS_ONLY, - minTtl: 3600, - defaultTtl: 7200, - maxTtl: 86400, - allowedMethods: [ - 'HEAD', - 'GET', - 'OPTIONS', - ], - cachedMethods: [ - 'HEAD', - 'GET', - 'OPTIONS', - ], - compress: true, - forwardedValues: { - queryString: false, - cookies: { - forward: 'none', - }, - headers: [ - 'Origin', - 'Access-Control-Request-Method', - 'Access-Control-Request-Headers', - ], - }, - }, - defaultRootObject: 'index.html', - enabled: true, - origins: [{ - domainName: s3BucketBrowserApp.bucketRegionalDomainName, - id: s3BucketBrowserApp.bucketName, - s3OriginConfig: { - originAccessIdentity: Fn.join('', [ - 'origin-access-identity/cloudfront/', - cloudfrontOriginAccessIdentity.originAccessIdentityId, - ]), - }, - }], - priceClass: cloudfront.PriceClass.PRICE_CLASS_ALL, - restrictions: { - geoRestriction: { - restrictionType: 'none', - locations: [], - }, - }, - viewerCertificate: { - cloudFrontDefaultCertificate: true, - minimumProtocolVersion: 'TLSv1.2_2019', - }, - logging: { - bucket: s3BucketbrowserAppLogs.bucketRegionalDomainName, - prefix: 'cloudfront/', - }, - } - }); this.MSAMBrowserURL = Fn.join('', [ 'https://', - cloudfrontDistribution.attrDomainName, + cloudfrontDistribution.domainName, ]); utils.setNagSuppressRules(cloudfrontDistribution, { @@ -235,7 +164,7 @@ export class MsamBrowserApp extends NestedStack { description: 'MSAM Lambda for custom CloudFormation resource for loading web application', memorySize: 2560, role: props.WebIAMRole, - runtime: lambda.Runtime.PYTHON_3_8, + runtime: lambda.Runtime.PYTHON_3_10, timeout: Duration.seconds(900), }); utils.setNagSuppressRules(webContentLambda, @@ -251,10 +180,6 @@ export class MsamBrowserApp extends NestedStack { id: 'W92', reason: 'Lambda does not need ReservedConcurrentExecutions.' }, - { - id: 'AwsSolutions-L1', - reason: 'Latest runtime version not supported at this time.', - }, ) // Web Content Custom Resource @@ -287,7 +212,7 @@ export class MsamBrowserApp extends NestedStack { description: 'MSAM Lambda for custom resource for invalidating CloudFront after update', memorySize: 2560, role: props.WebIAMRole, - runtime: lambda.Runtime.PYTHON_3_8, + runtime: lambda.Runtime.PYTHON_3_10, timeout: Duration.seconds(300), }); utils.setNagSuppressRules(webInvalidationResourceLambda, @@ -303,10 +228,6 @@ export class MsamBrowserApp extends NestedStack { id: 'W92', reason: 'Lambda does not need ReservedConcurrentExecutions.' }, - { - id: 'AwsSolutions-L1', - reason: 'Latest runtime version not supported at this time.', - }, ); // Web Invalidator Custom Resource @@ -317,7 +238,7 @@ export class MsamBrowserApp extends NestedStack { StackName: Aws.STACK_NAME, BUILD_STAMP: 'DEV_0_0_0', ZIP_DIGEST: 'ZIP_DIGEST_VALUE', - DistributionId: cloudfrontDistribution.attrId, + DistributionId: cloudfrontDistribution.distributionId, }, }); } diff --git a/source/cdk/lib/msam-core.ts b/source/cdk/lib/msam-core.ts index 3d2f57c9..71a065dd 100644 --- a/source/cdk/lib/msam-core.ts +++ b/source/cdk/lib/msam-core.ts @@ -8,6 +8,9 @@ import { aws_ssm as ssm, aws_sam as sam, cloudformation_include as cfnInc, + CfnCondition, + CfnParameter, + Fn, NestedStack, NestedStackProps, } from 'aws-cdk-lib'; @@ -65,6 +68,18 @@ export class MsamCore extends NestedStack { // Core Module Stack const coreStack = this.initStackFromTemplate('CoreModuleStack', '../dist/msam-core-release.template'); + + /** + * Parameters + */ + const sendAnonymizedData = new CfnParameter(this, 'SendAnonymizedData', { + default: 'No', + description: 'Enable or Disable Anonymized Data Reporting', + type: 'String', + allowedValues: ['Yes', 'No'], + constraintDescription: 'Please provide a value of Yes or No' + }); + /** * Resources */ @@ -251,6 +266,29 @@ export class MsamCore extends NestedStack { }, }; reportMetrics.description = 'MSAM Lambda for periodically emitting metrics to multiple targets'; + // override event enabled setting based on user setting + const sendAnonymizedDataCondition = new CfnCondition(this, 'sendAnonymizedDataCondition', { + expression: Fn.conditionEquals(sendAnonymizedData, 'Yes'), + }); + reportMetrics.events = { + ReportMetricsEvent: Fn.conditionIf( + sendAnonymizedDataCondition.logicalId, + { + Properties: { + Schedule: "rate(24 hours)", + Enabled: true, + }, + Type: 'Schedule' + }, + { + Properties: { + Schedule: "rate(24 hours)", + Enabled: false, + }, + Type: 'Schedule' + }, + ) + }; this.applyCommonLambdaProperties(reportMetrics, props.CoreIAMRole); // APIHandler diff --git a/source/cdk/lib/msam-dynamodb.ts b/source/cdk/lib/msam-dynamodb.ts index 75d8c177..f638857d 100644 --- a/source/cdk/lib/msam-dynamodb.ts +++ b/source/cdk/lib/msam-dynamodb.ts @@ -96,7 +96,7 @@ export class MsamDynamoDB extends NestedStack { SOLUTION_ID: 'AwsSolution/SO0048/%%VERSION%%', }, role: props.DynamoDBIAMRole, - runtime: lambda.Runtime.PYTHON_3_8, + runtime: lambda.Runtime.PYTHON_3_10, timeout: Duration.seconds(300), }); @@ -113,10 +113,6 @@ export class MsamDynamoDB extends NestedStack { id: 'W89', reason: 'Lambda does not need to be in a VPC.', }, - { - id: 'AwsSolutions-L1', - reason: 'Latest runtime version not supported at this time.', - }, ); /** diff --git a/source/cdk/lib/msam-events.ts b/source/cdk/lib/msam-events.ts index 97830aa5..3dd4e0d9 100644 --- a/source/cdk/lib/msam-events.ts +++ b/source/cdk/lib/msam-events.ts @@ -8,8 +8,6 @@ import { aws_iam as iam, aws_lambda as lambda, aws_s3 as s3, - CfnMapping, - CfnMappingProps, Duration, Fn, NestedStack, @@ -69,7 +67,7 @@ export class MsamEvents extends NestedStack { /** * Cfn Mapping */ - this.addMapping('SolutionId', { + utils.createCfnMapping(this, 'SolutionId', { mapping: { UserAgent: { Extra: 'AwsSolution/SO0048/%%VERSION%%', @@ -85,7 +83,7 @@ export class MsamEvents extends NestedStack { const collectorLambda = new lambda.Function(this, 'Collector', { handler: 'media_events.lambda_handler', description: 'MSAM Lambda for handling CloudWatch event notifications', - runtime: lambda.Runtime.PYTHON_3_8, + runtime: lambda.Runtime.PYTHON_3_10, code: lambda.Code.fromBucket( s3.Bucket.fromBucketName( this, @@ -120,10 +118,6 @@ export class MsamEvents extends NestedStack { id: 'W89', reason: 'Lambda does not need to be in a VPC.' }, - { - id: 'AwsSolutions-L1', - reason: 'Latest runtime version not supported at this time.', - }, ); // Collector Lambda Event Rule @@ -147,7 +141,7 @@ export class MsamEvents extends NestedStack { const alarmUpdaterLambda = new lambda.Function(this, 'AlarmUpdater', { handler: 'cloudwatch_alarm.lambda_handler', description: 'MSAM Lambda for handling CloudWatch alarm state change events.', - runtime: lambda.Runtime.PYTHON_3_8, + runtime: lambda.Runtime.PYTHON_3_10, role: props.EventsIAMRole, code: lambda.Code.fromBucket( s3.Bucket.fromBucketName( @@ -179,10 +173,6 @@ export class MsamEvents extends NestedStack { id: 'W89', reason: 'Lambda does not need to be in a VPC.' }, - { - id: 'AwsSolutions-L1', - reason: 'Latest runtime version not supported at this time.', - }, ); // Alarm Updater Lambda Event Rule @@ -197,10 +187,6 @@ export class MsamEvents extends NestedStack { }); } - addMapping(id: string, props?: CfnMappingProps) { - return new CfnMapping(this, id, props); - } - addEventRule(id: string, props?: events.RuleProps) { return new events.Rule(this, id, props); } diff --git a/source/cdk/lib/utils.ts b/source/cdk/lib/utils.ts index de8834fb..8e4107be 100644 --- a/source/cdk/lib/utils.ts +++ b/source/cdk/lib/utils.ts @@ -5,6 +5,7 @@ import { Aws, aws_servicecatalogappregistry as appRegistry, CfnMapping, + CfnMappingProps, CfnResource, CfnOutput, CfnOutputProps, @@ -216,4 +217,15 @@ function createCfnResourceAssociation(scope: Construct, id: string, props: appRe function createCfnAttributeGroupAssociation(scope: Construct, id: string, props: appRegistry.CfnAttributeGroupAssociationProps) { return new appRegistry.CfnAttributeGroupAssociation(scope, id, props); -} \ No newline at end of file +} + +/** + * Creates Cfn Mapping + * + * @param stack Stack which to apply CfnMappings to + * @param id Mapping Id + * @param props CfnMapping Properties + */ +export function createCfnMapping(stack: Stack, id: string, props?: CfnMappingProps) { + return new CfnMapping(stack, id, props); +} diff --git a/source/cdk/package-lock.json b/source/cdk/package-lock.json index 05695a4d..a052bc59 100644 --- a/source/cdk/package-lock.json +++ b/source/cdk/package-lock.json @@ -9,8 +9,8 @@ "version": "1.0.0", "license": "Apache-2.0", "dependencies": { - "aws-cdk-lib": "^2.67.0", - "constructs": "^10.0.0" + "aws-cdk-lib": "^2.87.0", + "constructs": "^10.2.69" }, "bin": { "cdk": "bin/media-services-application-mapper.js" @@ -18,8 +18,8 @@ "devDependencies": { "@types/jest": "^29.4.0", "@types/node": "^20.1.1", - "aws-cdk": "^2.67.0", - "cdk-nag": "^2.22.24", + "aws-cdk": "^2.87.0", + "cdk-nag": "^2.27.73", "jest": "^29.4.2", "ts-jest": "^29.0.5", "ts-node": "^10.9.1", @@ -40,9 +40,9 @@ } }, "node_modules/@aws-cdk/asset-awscli-v1": { - "version": "2.2.169", - "resolved": "https://registry.npmjs.org/@aws-cdk/asset-awscli-v1/-/asset-awscli-v1-2.2.169.tgz", - "integrity": "sha512-6lsgX4U3DryDNGUsymcyT8V4M7GVjmU6R57cN7Be6tIgINx1OK8Kl1ga/etpXxN1u9zGnxUmoQS7+/Xu+O/sNw==" + "version": "2.2.200", + "resolved": "https://registry.npmjs.org/@aws-cdk/asset-awscli-v1/-/asset-awscli-v1-2.2.200.tgz", + "integrity": "sha512-Kf5J8DfJK4wZFWT2Myca0lhwke7LwHcHBo+4TvWOGJrFVVKVuuiLCkzPPRBQQVDj0Vtn2NBokZAz8pfMpAqAKg==" }, "node_modules/@aws-cdk/asset-kubectl-v20": { "version": "2.1.1", @@ -50,9 +50,9 @@ "integrity": "sha512-U1ntiX8XiMRRRH5J1IdC+1t5CE89015cwyt5U63Cpk0GnMlN5+h9WsWMlKlPXZR4rdq/m806JRlBMRpBUB2Dhw==" }, "node_modules/@aws-cdk/asset-node-proxy-agent-v5": { - "version": "2.0.142", - "resolved": "https://registry.npmjs.org/@aws-cdk/asset-node-proxy-agent-v5/-/asset-node-proxy-agent-v5-2.0.142.tgz", - "integrity": "sha512-9NI2nBzpnBDhqlWF60AC6WG7ekNpd+z3uxZ1WgS0jwrv2Aco1MZIs8hs0tpABkT5Q8zTce/bPr98p31aIL0g9Q==" + "version": "2.0.165", + "resolved": "https://registry.npmjs.org/@aws-cdk/asset-node-proxy-agent-v5/-/asset-node-proxy-agent-v5-2.0.165.tgz", + "integrity": "sha512-bsyLQD/vqXQcc9RDmlM1XqiFNO/yewgVFXmkMcQkndJbmE/jgYkzewwYGrBlfL725hGLQipXq19+jwWwdsXQqg==" }, "node_modules/@babel/code-frame": { "version": "7.21.4", @@ -1246,9 +1246,9 @@ } }, "node_modules/aws-cdk": { - "version": "2.79.0", - "resolved": "https://registry.npmjs.org/aws-cdk/-/aws-cdk-2.79.0.tgz", - "integrity": "sha512-pVOw5QBbtmSA+PQmGwSR1qbtgC0caC6+Vc6bCZM4aK9nTh7iUXv4MKqXCUfxN6waNgYpweUCb29gxo6DOe99Yw==", + "version": "2.87.0", + "resolved": "https://registry.npmjs.org/aws-cdk/-/aws-cdk-2.87.0.tgz", + "integrity": "sha512-dBm74nl3dMUxoAzgjcfKnzJyoVNIV//B1sqDN11cC3LXEflYapcBxPxZHAyGcRXg5dW3m14dMdKVQfmt4N970g==", "dev": true, "bin": { "cdk": "bin/cdk" @@ -1261,9 +1261,9 @@ } }, "node_modules/aws-cdk-lib": { - "version": "2.79.0", - "resolved": "https://registry.npmjs.org/aws-cdk-lib/-/aws-cdk-lib-2.79.0.tgz", - "integrity": "sha512-uSQ/GBxnPj3bWRcA1/rTVYHzYksep7YDTGzuG0PDXaVf2kmIy1mcbOS0Phqr7sNE0L5vAjisWEygxyK3j0pLOQ==", + "version": "2.87.0", + "resolved": "https://registry.npmjs.org/aws-cdk-lib/-/aws-cdk-lib-2.87.0.tgz", + "integrity": "sha512-9kirXX7L7OP/yGmCbaYlkt5OAtowGiGw0AYFIQvSwvx/UU3aJO5XuDwAgDsvToDkRpBi0yX0bNwqa0DItu+C6A==", "bundleDependencies": [ "@balena/dockerignore", "case", @@ -1277,9 +1277,9 @@ "yaml" ], "dependencies": { - "@aws-cdk/asset-awscli-v1": "^2.2.165", + "@aws-cdk/asset-awscli-v1": "^2.2.177", "@aws-cdk/asset-kubectl-v20": "^2.1.1", - "@aws-cdk/asset-node-proxy-agent-v5": "^2.0.139", + "@aws-cdk/asset-node-proxy-agent-v5": "^2.0.148", "@balena/dockerignore": "^1.0.2", "case": "1.6.3", "fs-extra": "^11.1.1", @@ -1287,7 +1287,7 @@ "jsonschema": "^1.4.1", "minimatch": "^3.1.2", "punycode": "^2.3.0", - "semver": "^7.5.0", + "semver": "^7.5.1", "table": "^6.8.1", "yaml": "1.10.2" }, @@ -1503,7 +1503,7 @@ } }, "node_modules/aws-cdk-lib/node_modules/semver": { - "version": "7.5.0", + "version": "7.5.2", "inBundle": true, "license": "ISC", "dependencies": { @@ -1813,12 +1813,12 @@ ] }, "node_modules/cdk-nag": { - "version": "2.27.1", - "resolved": "https://registry.npmjs.org/cdk-nag/-/cdk-nag-2.27.1.tgz", - "integrity": "sha512-OlR8o7fls1XBPfdW099ADOEL1fvxzJ2A6dnL+AJ3e9j5On2WuziZhTpd8G48BGsTKPQoct7mzl9F51CN3xnm4g==", + "version": "2.27.73", + "resolved": "https://registry.npmjs.org/cdk-nag/-/cdk-nag-2.27.73.tgz", + "integrity": "sha512-lr7D5TczZ2qj/AHWumBKZhMdAcZqh6v4bHE8fKWHHF7eZcLGexW5YN38f0c2NLpAJCgkEU0ywYDT7h10ojlffg==", "dev": true, "peerDependencies": { - "aws-cdk-lib": "^2.45.0", + "aws-cdk-lib": "^2.78.0", "constructs": "^10.0.5" } }, @@ -1923,11 +1923,11 @@ "dev": true }, "node_modules/constructs": { - "version": "10.2.19", - "resolved": "https://registry.npmjs.org/constructs/-/constructs-10.2.19.tgz", - "integrity": "sha512-9UYEUF/UEaLz+AdyY+93KCZSuLLyCQb4azkq8z9cKiJhY7f+1l3yBWGLIY5DI7xyIbNPJ/9uZPuLi50jKUhLVg==", + "version": "10.2.69", + "resolved": "https://registry.npmjs.org/constructs/-/constructs-10.2.69.tgz", + "integrity": "sha512-0AiM/uQe5Uk6JVe/62oolmSN2MjbFQkOlYrM3fFGZLKuT+g7xlAI10EebFhyCcZwI2JAcWuWCmmCAyCothxjuw==", "engines": { - "node": ">= 14.17.0" + "node": ">= 16.14.0" } }, "node_modules/convert-source-map": { diff --git a/source/cdk/package.json b/source/cdk/package.json index 8a3fec2a..317bf5a4 100644 --- a/source/cdk/package.json +++ b/source/cdk/package.json @@ -23,15 +23,15 @@ "devDependencies": { "@types/jest": "^29.4.0", "@types/node": "^20.1.1", - "aws-cdk": "^2.67.0", - "cdk-nag": "^2.22.24", + "aws-cdk": "^2.87.0", + "cdk-nag": "^2.27.73", "jest": "^29.4.2", "ts-jest": "^29.0.5", "ts-node": "^10.9.1", "typescript": "^5.0.4" }, "dependencies": { - "aws-cdk-lib": "^2.67.0", - "constructs": "^10.0.0" + "aws-cdk-lib": "^2.87.0", + "constructs": "^10.2.69" } } diff --git a/source/cdk/test/__snapshots__/media-services-application-mapper.test.ts.snap b/source/cdk/test/__snapshots__/media-services-application-mapper.test.ts.snap index a141cf11..149760c7 100644 --- a/source/cdk/test/__snapshots__/media-services-application-mapper.test.ts.snap +++ b/source/cdk/test/__snapshots__/media-services-application-mapper.test.ts.snap @@ -4,6 +4,11 @@ exports[`media-services-application-mapper snapshot test 1`] = ` { "Description": "(SO0048) Media Services Application Mapper Root Stack %%VERSION%%", "Mappings": { + "AnonymizedData": { + "SendAnonymizedData": { + "Data": "Yes", + }, + }, "Solution": { "Data": { "AppRegistryApplicationName": "media-services-application-mapper", @@ -76,7 +81,7 @@ exports[`media-services-application-mapper snapshot test 1`] = ` { "Fn::GetAtt": [ "BrowserAppModuleStackNestedStackBrowserAppModuleStackNestedStackResource6F2C1DA7", - "Outputs.MediaServicesApplicationMapperBrowserAppModuleStackMSAMAppBucketCloudFrontDistributionA6217434DomainName", + "Outputs.MediaServicesApplicationMapperBrowserAppModuleStackMSAMAppBucketCloudFrontDistribution4829FDD0DomainName", ], }, ], @@ -304,6 +309,13 @@ exports[`media-services-application-mapper snapshot test 1`] = ` "DeletionPolicy": "Delete", "Properties": { "Parameters": { + "SendAnonymizedData": { + "Fn::FindInMap": [ + "AnonymizedData", + "SendAnonymizedData", + "Data", + ], + }, "referencetoMediaServicesApplicationMapperCacheItemTTL6DD8B4F7Ref": { "Ref": "CacheItemTTL", }, diff --git a/source/cdk/test/__snapshots__/msam-browser-app.test.ts.snap b/source/cdk/test/__snapshots__/msam-browser-app.test.ts.snap index 792f1b6c..63c6c491 100644 --- a/source/cdk/test/__snapshots__/msam-browser-app.test.ts.snap +++ b/source/cdk/test/__snapshots__/msam-browser-app.test.ts.snap @@ -4,10 +4,10 @@ exports[`msam-browser-app snapshot test 1`] = ` { "Description": "Media Services Application Mapper Browser Application %%VERSION%%", "Outputs": { - "MediaServicesApplicationMapperBrowserAppModuleStackMSAMAppBucketCloudFrontDistributionA6217434DomainName": { + "MediaServicesApplicationMapperBrowserAppModuleStackMSAMAppBucketCloudFrontDistribution4829FDD0DomainName": { "Value": { "Fn::GetAtt": [ - "MSAMAppBucketCloudFrontDistribution", + "MSAMAppBucketCloudFrontDistributionCA6CDA4B", "DomainName", ], }, @@ -19,7 +19,46 @@ exports[`msam-browser-app snapshot test 1`] = ` }, }, "Resources": { - "MSAMAppBucketCloudFrontDistribution": { + "MSAMAppBucketCloudFrontCachePolicyAC6B69B5": { + "Properties": { + "CachePolicyConfig": { + "DefaultTTL": 7200, + "MaxTTL": 86400, + "MinTTL": 3600, + "Name": { + "Fn::Join": [ + "", + [ + "MediaServicesApplicationMapperBrowserAppModuleStackMSAMAppBucketCloudFrontCachePolicy46E867D5-", + { + "Ref": "AWS::Region", + }, + ], + ], + }, + "ParametersInCacheKeyAndForwardedToOrigin": { + "CookiesConfig": { + "CookieBehavior": "none", + }, + "EnableAcceptEncodingBrotli": false, + "EnableAcceptEncodingGzip": false, + "HeadersConfig": { + "HeaderBehavior": "whitelist", + "Headers": [ + "Origin", + "Access-Control-Request-Method", + "Access-Control-Request-Headers", + ], + }, + "QueryStringsConfig": { + "QueryStringBehavior": "none", + }, + }, + }, + }, + "Type": "AWS::CloudFront::CachePolicy", + }, + "MSAMAppBucketCloudFrontDistributionCA6CDA4B": { "Metadata": { "cdk_nag": { "rules_to_suppress": [ @@ -61,37 +100,26 @@ exports[`msam-browser-app snapshot test 1`] = ` }, "DefaultCacheBehavior": { "AllowedMethods": [ - "HEAD", "GET", + "HEAD", "OPTIONS", ], + "CachePolicyId": { + "Ref": "MSAMAppBucketCloudFrontCachePolicyAC6B69B5", + }, "CachedMethods": [ - "HEAD", "GET", + "HEAD", "OPTIONS", ], "Compress": true, - "DefaultTTL": 7200, - "ForwardedValues": { - "Cookies": { - "Forward": "none", - }, - "Headers": [ - "Origin", - "Access-Control-Request-Method", - "Access-Control-Request-Headers", - ], - "QueryString": false, - }, - "MaxTTL": 86400, - "MinTTL": 3600, - "TargetOriginId": { - "Ref": "MSAMBrowserAppBucketB112E0BD", - }, + "TargetOriginId": "MediaServicesApplicationMapperBrowserAppModuleStackMSAMAppBucketCloudFrontDistributionOrigin1939BB4DB", "ViewerProtocolPolicy": "https-only", }, "DefaultRootObject": "index.html", "Enabled": true, + "HttpVersion": "http2", + "IPV6Enabled": true, "Logging": { "Bucket": { "Fn::GetAtt": [ @@ -109,9 +137,7 @@ exports[`msam-browser-app snapshot test 1`] = ` "RegionalDomainName", ], }, - "Id": { - "Ref": "MSAMBrowserAppBucketB112E0BD", - }, + "Id": "MediaServicesApplicationMapperBrowserAppModuleStackMSAMAppBucketCloudFrontDistributionOrigin1939BB4DB", "S3OriginConfig": { "OriginAccessIdentity": { "Fn::Join": [ @@ -119,7 +145,7 @@ exports[`msam-browser-app snapshot test 1`] = ` [ "origin-access-identity/cloudfront/", { - "Ref": "MSAMAppBucketOriginAccessIdentity73947A70", + "Ref": "MSAMAppBucketCloudFrontDistributionOrigin1S3OriginD56D6A8D", }, ], ], @@ -128,62 +154,38 @@ exports[`msam-browser-app snapshot test 1`] = ` }, ], "PriceClass": "PriceClass_All", - "Restrictions": { - "GeoRestriction": { - "Locations": [], - "RestrictionType": "none", - }, - }, - "ViewerCertificate": { - "CloudFrontDefaultCertificate": true, - "MinimumProtocolVersion": "TLSv1.2_2019", - }, }, }, "Type": "AWS::CloudFront::Distribution", }, - "MSAMAppBucketOriginAccessIdentity73947A70": { - "Properties": { - "CloudFrontOriginAccessIdentityConfig": { - "Comment": { - "Fn::Join": [ - "", - [ - "Origin Access Identity for ", - { - "Ref": "MSAMBrowserAppBucketB112E0BD", - }, - ], - ], - }, - }, - }, - "Type": "AWS::CloudFront::CloudFrontOriginAccessIdentity", - }, - "MSAMBrowserAppBucketB112E0BD": { - "DeletionPolicy": "Retain", + "MSAMAppBucketCloudFrontDistributionOrigin1S3OriginD56D6A8D": { "Metadata": { "cdk_nag": { "rules_to_suppress": [ { - "id": "AwsSolutions-S2", - "reason": "Public access blocked by default", + "id": "AwsSolutions-CFR4", + "reason": "If the distribution uses the CloudFront domain name such as d111111abcdef8.cloudfront.net (you set CloudFrontDefaultCertificate to true), CloudFront automatically sets the security policy to TLSv1 regardless of the value that you set here.", }, { - "id": "AwsSolutions-S10", - "reason": "HTTPS requirement not supported at this time.", + "id": "AwsSolutions-CFR1", + "reason": "Geo restriction not supported at this time.", }, - ], - }, - "cfn_nag": { - "rules_to_suppress": [ { - "id": "W51", - "reason": "This is the logging bucket. No bucket policy needed.", + "id": "AwsSolutions-CFR2", + "reason": "AWS WAF integration not supported at this time.", }, ], }, }, + "Properties": { + "CloudFrontOriginAccessIdentityConfig": { + "Comment": "Identity for MediaServicesApplicationMapperBrowserAppModuleStackMSAMAppBucketCloudFrontDistributionOrigin1939BB4DB", + }, + }, + "Type": "AWS::CloudFront::CloudFrontOriginAccessIdentity", + }, + "MSAMBrowserAppBucketB112E0BD": { + "DeletionPolicy": "Retain", "Properties": { "BucketEncryption": { "ServerSideEncryptionConfiguration": [ @@ -228,70 +230,7 @@ exports[`msam-browser-app snapshot test 1`] = ` "Type": "AWS::S3::Bucket", "UpdateReplacePolicy": "Retain", }, - "MSAMBrowserAppBucketPolicy": { - "Metadata": { - "cdk_nag": { - "rules_to_suppress": [ - { - "id": "AwsSolutions-S10", - "reason": "HTTPS requirement not supported at this time.", - }, - ], - }, - }, - "Properties": { - "Bucket": { - "Ref": "MSAMBrowserAppBucketB112E0BD", - }, - "PolicyDocument": { - "Statement": [ - { - "Action": "s3:GetObject", - "Effect": "Allow", - "Principal": { - "CanonicalUser": { - "Fn::GetAtt": [ - "MSAMAppBucketOriginAccessIdentity73947A70", - "S3CanonicalUserId", - ], - }, - }, - "Resource": { - "Fn::Join": [ - "", - [ - { - "Fn::GetAtt": [ - "MSAMBrowserAppBucketB112E0BD", - "Arn", - ], - }, - "/*", - ], - ], - }, - }, - ], - "Version": "2012-10-17", - }, - }, - "Type": "AWS::S3::BucketPolicy", - }, "MSAMBrowserAppBucketPolicy472FC56D": { - "Metadata": { - "cdk_nag": { - "rules_to_suppress": [ - { - "id": "AwsSolutions-S2", - "reason": "Public access blocked by default", - }, - { - "id": "AwsSolutions-S10", - "reason": "HTTPS requirement not supported at this time.", - }, - ], - }, - }, "Properties": { "Bucket": { "Ref": "MSAMBrowserAppBucketB112E0BD", @@ -332,6 +271,32 @@ exports[`msam-browser-app snapshot test 1`] = ` }, ], }, + { + "Action": "s3:GetObject", + "Effect": "Allow", + "Principal": { + "CanonicalUser": { + "Fn::GetAtt": [ + "MSAMAppBucketCloudFrontDistributionOrigin1S3OriginD56D6A8D", + "S3CanonicalUserId", + ], + }, + }, + "Resource": { + "Fn::Join": [ + "", + [ + { + "Fn::GetAtt": [ + "MSAMBrowserAppBucketB112E0BD", + "Arn", + ], + }, + "/*", + ], + ], + }, + }, ], "Version": "2012-10-17", }, @@ -340,36 +305,6 @@ exports[`msam-browser-app snapshot test 1`] = ` }, "MSAMBrowserAppLoggingBucket898E5B4B": { "DeletionPolicy": "Retain", - "Metadata": { - "cdk_nag": { - "rules_to_suppress": [ - { - "id": "AwsSolutions-S1", - "reason": "This is the logging bucket. No access logging needed.", - }, - { - "id": "AwsSolutions-S2", - "reason": "Public access blocked by default", - }, - { - "id": "AwsSolutions-S10", - "reason": "HTTPS requirement not supported at this time.", - }, - ], - }, - "cfn_nag": { - "rules_to_suppress": [ - { - "id": "W35", - "reason": "This is the logging bucket. No access logging needed.", - }, - { - "id": "W51", - "reason": "This is the logging bucket. No bucket policy needed.", - }, - ], - }, - }, "Properties": { "AccessControl": "LogDeliveryWrite", "BucketEncryption": { @@ -396,6 +331,13 @@ exports[`msam-browser-app snapshot test 1`] = ` }, ], }, + "OwnershipControls": { + "Rules": [ + { + "ObjectOwnership": "ObjectWriter", + }, + ], + }, "PublicAccessBlockConfiguration": { "BlockPublicAcls": true, "BlockPublicPolicy": true, @@ -410,24 +352,6 @@ exports[`msam-browser-app snapshot test 1`] = ` "UpdateReplacePolicy": "Retain", }, "MSAMBrowserAppLoggingBucketPolicy4483AFF0": { - "Metadata": { - "cdk_nag": { - "rules_to_suppress": [ - { - "id": "AwsSolutions-S1", - "reason": "This is the logging bucket. No access logging needed.", - }, - { - "id": "AwsSolutions-S2", - "reason": "Public access blocked by default", - }, - { - "id": "AwsSolutions-S10", - "reason": "HTTPS requirement not supported at this time.", - }, - ], - }, - }, "Properties": { "Bucket": { "Ref": "MSAMBrowserAppLoggingBucket898E5B4B", @@ -497,14 +421,6 @@ exports[`msam-browser-app snapshot test 1`] = ` }, "MSAMWebContentResourceBB737197": { "Metadata": { - "cdk_nag": { - "rules_to_suppress": [ - { - "id": "AwsSolutions-L1", - "reason": "Latest runtime version not supported at this time.", - }, - ], - }, "cfn_nag": { "rules_to_suppress": [ { @@ -550,21 +466,13 @@ exports[`msam-browser-app snapshot test 1`] = ` "Role": { "Ref": "referencetoMediaServicesApplicationMapperIAMModuleStackNestedStackIAMModuleStackNestedStackResourceF97053D6OutputsMediaServicesApplicationMapperIAMModuleStackWebRole1122C569Arn", }, - "Runtime": "python3.8", + "Runtime": "python3.10", "Timeout": 900, }, "Type": "AWS::Lambda::Function", }, "MSAMWebInvalidationResource94603649": { "Metadata": { - "cdk_nag": { - "rules_to_suppress": [ - { - "id": "AwsSolutions-L1", - "reason": "Latest runtime version not supported at this time.", - }, - ], - }, "cfn_nag": { "rules_to_suppress": [ { @@ -610,7 +518,7 @@ exports[`msam-browser-app snapshot test 1`] = ` "Role": { "Ref": "referencetoMediaServicesApplicationMapperIAMModuleStackNestedStackIAMModuleStackNestedStackResourceF97053D6OutputsMediaServicesApplicationMapperIAMModuleStackWebRole1122C569Arn", }, - "Runtime": "python3.8", + "Runtime": "python3.10", "Timeout": 300, }, "Type": "AWS::Lambda::Function", @@ -623,10 +531,7 @@ exports[`msam-browser-app snapshot test 1`] = ` "Ref": "MSAMBrowserAppBucketB112E0BD", }, "DistributionId": { - "Fn::GetAtt": [ - "MSAMAppBucketCloudFrontDistribution", - "Id", - ], + "Ref": "MSAMAppBucketCloudFrontDistributionCA6CDA4B", }, "ServiceToken": { "Fn::GetAtt": [ diff --git a/source/cdk/test/__snapshots__/msam-core.test.ts.snap b/source/cdk/test/__snapshots__/msam-core.test.ts.snap index 06b2975c..4498b214 100644 --- a/source/cdk/test/__snapshots__/msam-core.test.ts.snap +++ b/source/cdk/test/__snapshots__/msam-core.test.ts.snap @@ -3,6 +3,16 @@ exports[`msam-core snapshot test 1`] = ` { "AWSTemplateFormatVersion": "2010-09-09", + "Conditions": { + "sendAnonymizedDataCondition": { + "Fn::Equals": [ + { + "Ref": "SendAnonymizedData", + }, + "Yes", + ], + }, + }, "Description": "Media Services Application Mapper REST API and Tasks %%VERSION%%", "Outputs": { "APIHandlerArn": { @@ -40,6 +50,16 @@ exports[`msam-core snapshot test 1`] = ` }, }, "Parameters": { + "SendAnonymizedData": { + "AllowedValues": [ + "Yes", + "No", + ], + "ConstraintDescription": "Please provide a value of Yes or No", + "Default": "No", + "Description": "Enable or Disable Anonymized Data Reporting", + "Type": "String", + }, "referencetoMediaServicesApplicationMapperCacheItemTTL6DD8B4F7Ref": { "Type": "String", }, @@ -786,10 +806,23 @@ exports[`msam-core snapshot test 1`] = ` }, "Events": { "ReportMetricsEvent": { - "Properties": { - "Schedule": "rate(24 hours)", - }, - "Type": "Schedule", + "Fn::If": [ + "sendAnonymizedDataCondition", + { + "Properties": { + "Enabled": true, + "Schedule": "rate(24 hours)", + }, + "Type": "Schedule", + }, + { + "Properties": { + "Enabled": false, + "Schedule": "rate(24 hours)", + }, + "Type": "Schedule", + }, + ], }, }, "Handler": "app.report_metrics", diff --git a/source/cdk/test/__snapshots__/msam-dynamodb.test.ts.snap b/source/cdk/test/__snapshots__/msam-dynamodb.test.ts.snap index 9ceb1dca..18d3b38d 100644 --- a/source/cdk/test/__snapshots__/msam-dynamodb.test.ts.snap +++ b/source/cdk/test/__snapshots__/msam-dynamodb.test.ts.snap @@ -277,14 +277,6 @@ exports[`msam-dynamodb snapshot test 1`] = ` }, "DefaultSettingsResource66AC9BCF": { "Metadata": { - "cdk_nag": { - "rules_to_suppress": [ - { - "id": "AwsSolutions-L1", - "reason": "Latest runtime version not supported at this time.", - }, - ], - }, "cfn_nag": { "rules_to_suppress": [ { @@ -329,7 +321,7 @@ exports[`msam-dynamodb snapshot test 1`] = ` "Role": { "Ref": "referencetoMediaServicesApplicationMapperIAMModuleStackNestedStackIAMModuleStackNestedStackResourceF97053D6OutputsMediaServicesApplicationMapperIAMModuleStackDynamoDBRole0562A431Arn", }, - "Runtime": "python3.8", + "Runtime": "python3.10", "Timeout": 300, }, "Type": "AWS::Lambda::Function", diff --git a/source/cdk/test/__snapshots__/msam-events.test.ts.snap b/source/cdk/test/__snapshots__/msam-events.test.ts.snap index c180497c..7998fcf6 100644 --- a/source/cdk/test/__snapshots__/msam-events.test.ts.snap +++ b/source/cdk/test/__snapshots__/msam-events.test.ts.snap @@ -33,14 +33,6 @@ exports[`msam-events snapshot test 1`] = ` "Resources": { "AlarmUpdater6FDC3F1D": { "Metadata": { - "cdk_nag": { - "rules_to_suppress": [ - { - "id": "AwsSolutions-L1", - "reason": "Latest runtime version not supported at this time.", - }, - ], - }, "cfn_nag": { "rules_to_suppress": [ { @@ -97,7 +89,7 @@ exports[`msam-events snapshot test 1`] = ` "Role": { "Ref": "referencetoMediaServicesApplicationMapperIAMModuleStackNestedStackIAMModuleStackNestedStackResourceF97053D6OutputsMediaServicesApplicationMapperIAMModuleStackEventsRole2AFF40D1Arn", }, - "Runtime": "python3.8", + "Runtime": "python3.10", "Timeout": 60, }, "Type": "AWS::Lambda::Function", @@ -148,14 +140,6 @@ exports[`msam-events snapshot test 1`] = ` }, "Collector9EBA7CF5": { "Metadata": { - "cdk_nag": { - "rules_to_suppress": [ - { - "id": "AwsSolutions-L1", - "reason": "Latest runtime version not supported at this time.", - }, - ], - }, "cfn_nag": { "rules_to_suppress": [ { @@ -221,7 +205,7 @@ exports[`msam-events snapshot test 1`] = ` "Role": { "Ref": "referencetoMediaServicesApplicationMapperIAMModuleStackNestedStackIAMModuleStackNestedStackResourceF97053D6OutputsMediaServicesApplicationMapperIAMModuleStackEventsRole2AFF40D1Arn", }, - "Runtime": "python3.8", + "Runtime": "python3.10", "Timeout": 60, }, "Type": "AWS::Lambda::Function", diff --git a/source/events/media_events.py b/source/events/media_events.py index 496bdcfd..badcf5f2 100644 --- a/source/events/media_events.py +++ b/source/events/media_events.py @@ -9,7 +9,7 @@ import datetime import os import json -from random import randint +import secrets from urllib.parse import unquote import boto3 @@ -126,8 +126,7 @@ def lambda_handler(event, _): handle_alerts(event) # set the rest of the information needed for storing as regular CWE # give timestamp a millisecond precision since it's sort key in CWE table - # Bandit B311: randint not used for cryptographic purposes - event["timestamp"] = event["timestamp"] * 1000 + randint(1, 999) # nosec + event["timestamp"] = event["timestamp"] * 1000 + secrets.randbelow(999) + 1 event["data"] = json.dumps(event["detail"]) event["type"] = event["detail-type"] if "eventName" in event["detail"]: diff --git a/source/html/js/app/ui/settings_menu.js b/source/html/js/app/ui/settings_menu.js index ca011d40..baeeb4b0 100644 --- a/source/html/js/app/ui/settings_menu.js +++ b/source/html/js/app/ui/settings_menu.js @@ -143,7 +143,7 @@ if (connections.get_current() !== null) { $("#save_endpoint_connection").on("click", () => { try { // trim the string, normalize the link, remove any trailing slash - const endpoint = filterXSS($("#input_endpoint_url").val().trim()).replace(/\/+$/, ""); + const endpoint = filterXSS($("#input_endpoint_url").val().trim()).replace(/\/$/, ""); const apiKey = filterXSS($("#input_endpoint_key").val().trim()); const store_locally = $("#connectionRemember").prop("checked"); console.log("store locally = " + store_locally); diff --git a/source/html/js/app/ui/util.js b/source/html/js/app/ui/util.js index 266f9b3b..6bfb5b8a 100644 --- a/source/html/js/app/ui/util.js +++ b/source/html/js/app/ui/util.js @@ -6,13 +6,16 @@ export const makeid = function (id_len = 10) { const possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; for (let i = 0; i < id_len; i++) { - text += possible.charAt(Math.floor(Math.random() * possible.length)); + text += possible.charAt(get_random_number(possible.length)); } return text; }; export function get_random_number(max) { - return Math.floor(Math.random() * Math.floor(max)); + const randomBuffer = new Uint32Array(1); + crypto.getRandomValues(randomBuffer); + const randomNumber = randomBuffer[0] / (0xffffffff + 1); + return Math.floor(randomNumber * (max)); } export function vary(value, limit) { diff --git a/source/msam/app.py b/source/msam/app.py index 585e6138..76a0b3e0 100644 --- a/source/msam/app.py +++ b/source/msam/app.py @@ -480,7 +480,7 @@ def generate_metrics(_): @app.schedule(Rate(METRICS_REPORTING_RATE_HOURS, unit=Rate.HOURS)) def report_metrics(_): """ - Entry point for the CloudWatch scheduled task to report anonymous resource metrics. + Entry point for the CloudWatch scheduled task to report anonymized resource metrics. """ return periodic_handlers.report_metrics(STACKNAME, METRICS_REPORTING_RATE_HOURS) diff --git a/source/msam/chalicelib/connections.py b/source/msam/chalicelib/connections.py index 86878619..274e7824 100644 --- a/source/msam/chalicelib/connections.py +++ b/source/msam/chalicelib/connections.py @@ -11,7 +11,7 @@ from urllib.parse import urlparse from botocore.exceptions import ClientError -from fuzzywuzzy import fuzz +from difflib import SequenceMatcher from jsonpath_ng import parse from chalicelib import cache @@ -680,8 +680,7 @@ def mediapackage_endpoint_cloudfront_distribution_by_origin_url_ddb_items(): origin_partial_url = f'{item["DomainName"]}/{item["OriginPath"]}' for mp_endpoint in mediapackage_ep_cached: mp_endpoint_data = json.loads(mp_endpoint["data"]) - ratio = fuzz.ratio(origin_partial_url, - mp_endpoint_data["Url"]) + ratio = round(SequenceMatcher(None, origin_partial_url, mp_endpoint_data["Url"]).ratio() * 100) if ratio >= min_ratio: config = { "from": mp_endpoint["arn"], @@ -909,6 +908,9 @@ def mediaconnect_flow_mediaconnect_flow_ddb_items(): inner_flow_data["FlowArn"], outer_flow_data["FlowArn"], connection_type, config)) + # if the source is entitlement, there won't be any matching inner flows + # and this Flow won't have a VPC source - bail early + continue # More Info: https://bandit.readthedocs.io/en/latest/plugins/b110_try_except_pass.html except Exception: #nosec pass diff --git a/source/msam/chalicelib/nodes.py b/source/msam/chalicelib/nodes.py index 7dcb9def..74bc30da 100644 --- a/source/msam/chalicelib/nodes.py +++ b/source/msam/chalicelib/nodes.py @@ -597,6 +597,8 @@ def ec2_instances(region): #reformat the tags before appending to data final_tags[tag["Key"]] = tag["Value"] instance['Tags'] = final_tags + else: + instance['Tags'] = {} items.append(instance) return items diff --git a/source/msam/chalicelib/periodic.py b/source/msam/chalicelib/periodic.py index 76b76bdf..27902b90 100644 --- a/source/msam/chalicelib/periodic.py +++ b/source/msam/chalicelib/periodic.py @@ -405,7 +405,7 @@ def generate_metrics(stackname): def report_metrics(stackname, hours): """ - This function is responsible for reporting anonymous resource counts. + This function is responsible for reporting anonymized resource counts. """ cloudwatch = boto3.resource('cloudwatch', config=MSAM_BOTO3_CONFIG) uuid = msam_settings.get_setting('uuid') diff --git a/source/msam/chalicelib/tags.py b/source/msam/chalicelib/tags.py index cf39c35e..fa6e1d74 100644 --- a/source/msam/chalicelib/tags.py +++ b/source/msam/chalicelib/tags.py @@ -82,7 +82,7 @@ def update_diagrams(): print(f"new diagram id {view_id}") diagrams.append({"name": diagram_name, "view_id": view_id}) settings.put_setting("diagrams", diagrams) - print("created diagram id {view_id}") + print(f"created diagram id {view_id}") # check if this node is already on the diagram layout if not layout.has_node(view_id, arn): print(f"adding node {arn} to diagram id {view_id}") diff --git a/source/msam/db/lambda_function.py b/source/msam/db/lambda_function.py index 81dade21..4521e714 100644 --- a/source/msam/db/lambda_function.py +++ b/source/msam/db/lambda_function.py @@ -159,7 +159,7 @@ def make_default_settings(settings_table): print("added default tile-view setting") except ClientError: print("tile-view setting exists") - # stack uuid for anonymous metrics + # stack uuid for anonymized metrics try: table.put_item(Item={ "id": "uuid", diff --git a/source/msam/requirements.txt b/source/msam/requirements.txt index 73228e03..c7d9e6b2 100644 --- a/source/msam/requirements.txt +++ b/source/msam/requirements.txt @@ -1,6 +1,5 @@ networkx jsonpath_ng -fuzzywuzzy stringcase requests defusedxml diff --git a/source/msam/test/test_connections.py b/source/msam/test/test_connections.py index 4e132ec2..e0ee399a 100644 --- a/source/msam/test/test_connections.py +++ b/source/msam/test/test_connections.py @@ -81,6 +81,23 @@ \"Sources\": [{\"EntitlementArn\": \"arn:aws:mediaconnect:us-east-1:1234567890:entitlement:1-CAVaVVRQUAMLAF0P-43e6ff4eb1d4:Multiplex-2911217-pipeline-0\", \ \"Name\": \"i075dcd8225a\", \"SourceArn\": \"arn:aws:mediaconnect:us-east-1:1234567890:source:1-WVZVV1IMAQhXBVEI-c67d3528bbe6:i075dcd8225a\"}], \ \"Status\": \"STANDBY\", \"Tags\": {}}"}] +CACHED_MC_FLOWS_2 = [{"data": "{\"AvailabilityZone\": \"us-east-1a\", \"EgressIp\": \"54.145.77.151\", \"Entitlements\": [], \ + \"FlowArn\": \"arn:aws:mediaconnect:us-east-1:1234567890:flow:1-WVZVV1IMAQhXBVEI-c67d3528bbe6:Plex-Test-Out-0\", \ + \"MediaStreams\": [], \"Name\": \"test\", \"Outputs\": [{\"Description\": \"test\", \"ListenerAddress\": \"10.1.2.3\", \"Name\": \"test\", \ + \"OutputArn\": \"arn:aws:mediaconnect:us-east-1:1234567890:output:1-Cg8ABVcLBAQHA1BS-d8f6412277e1:Plex-Test-Out-0\", \"Port\": 1025, \ + \"Transport\": {\"MinLatency\": 1000, \"Protocol\": \"srt-listener\"}, \"VpcInterfaceAttachment\": { \ + \"VpcInterfaceName\": \"vpc_interface\"}}], \"Source\": {\"DataTransferSubscriberFeePercent\": 100, \"Decryption\": { \ + \"Algorithm\": \"aes256\", \"KeyType\": \"static-key\", \"RoleArn\": \"arn:aws:iam::1234567890:role/secrets\", \ + \"SecretArn\": \"arn:aws:secretsmanager:us-east-1:1234567890:secret:mysecret-aBc123\"}, \ + \"EntitlementArn\": \"arn:aws:mediaconnect:us-east-1:1234567890:entitlement:1-CAVaVVRQUAMLAF0P-43e6ff4eb1d4:Plex-Test-Out-0\", \ + \"Name\": \"test\", \"SourceArn\": \"arn:aws:mediaconnect:us-east-1:1234567890:source:1-WVZVV1IMAQhXBVEI-c67d3528bbe6:Plex-Test-Out-0\"}, \ + \"Sources\": [{\"DataTransferSubscriberFeePercent\": 100, \"Decryption\": {\"Algorithm\": \"aes256\", \"KeyType\": \"static-key\", \ + \"RoleArn\": \"arn:aws:iam::1234567890:role/role\", \"SecretArn\": \"arn:aws:secretsmanager:us-east-1:1234567890:secret:mysecret-aBc123\"}, \ + \"EntitlementArn\": \"arn:aws:mediaconnect:us-east-1:1234567890:entitlement:1-CAVaVVRQUAMLAF0P-43e6ff4eb1d4:Plex-Test-Out-0\", \"Name\": \"test\", \ + \"SourceArn\": \"arn:aws:mediaconnect:us-east-1:1234567890:source:1-WVZVV1IMAQhXBVEI-c67d3528bbe6:Plex-Test-Out-0\"}], \"Status\": \"STANDBY\", \ + \"VpcInterfaces\": [{\"Name\": \"vpc_interface\", \"NetworkInterfaceIds\": [\"eni-01234456789012345\"], \"NetworkInterfaceType\": \"ena\", \ + \"RoleArn\": \"arn:aws:iam::1234567890:role/role\", \"SecurityGroupIds\": [\"sg-01234456789012345\"], \ + \"SubnetId\": \"subnet-01234456789012345\"}], \"VpcSubnet\": {\"vpc_interface\": \"subnet-01234456789012345\"}, \"Tags\": {}}"}] CACHED_S3 = [{"arn": "arn:aws:s3:::msam-upgrader-browserappmodu-msambrowserappbucket-1f8ur1bq93ntv", "data": "{\"Name\": \"msam-upgrader-browserappmodu-msambrowserappbucket-1f8ur1bq93ntv\", \"CreationDate\": \"2021-03-23 23:29:43+00:00\", \ \"Tags\": {\"aws:cloudformation:stack-id\": \"arn:aws:cloudformation:us-east-1:1234567890:stack/MSAM-Upgrader-BrowserAppModuleStack-8HNMBO88Y67O/a13d6900-8c2f-11eb-98d8-12f3521c88a3\", \ @@ -441,7 +458,7 @@ def test_mediaconnect_flow_mediaconnect_flow_ddb_items(self, patched_env, patche Test the mediaconnect_flow_mediaconnect_flow_ddb_items function """ from chalicelib import connections, cache - with patch.object(cache, 'cached_by_service', side_effect=(CACHED_MC_FLOWS, CACHED_MC_FLOWS)): + with patch.object(cache, 'cached_by_service', side_effect=(CACHED_MC_FLOWS, CACHED_MC_FLOWS, CACHED_MC_FLOWS_2)): items = connections.mediaconnect_flow_mediaconnect_flow_ddb_items() self.assertEqual(len(items), 1) self.assertEqual(items[0]['arn'], 'arn:aws:mediaconnect:us-east-1:1234567890:entitlement:1-CAVaVVRQUAMLAF0P-43e6ff4eb1d4:Multiplex-2911217-pipeline-0:arn:aws:mediaconnect:us-east-1:1234567890:flow:1-WVZVV1IMAQhXBVEI-c67d3528bbe6:Plex-Test-Out-0')